Skip to contentSkip to conversation

qdev: uglify qdev_set_prop_bin() to deal with qemu_malloc(0) aborting.

PATCH New Gerd Hoffmann 1 participant 1 message May 29, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qdev: uglify qdev_set_prop_bin() to deal with qemu_malloc(0) aborting.

Without that patch attempts to store zero-length binary attributes will kill qemu.

Incremental fix for the "qdev: add string and binary properties" patch.

---
 hw/qdev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/qdev.c +2 -1
index 74a2892..62cff6b 100644
@@ -166,7 +166,8 @@ void qdev_set_prop_bin(DeviceState *dev, const char *name, const uint8_t *bin, s
 
     prop = create_prop(dev, name);
     prop->type = PROP_BIN;
-    prop->value.bin = qemu_malloc(len);
+    if (len)
+        prop->value.bin = qemu_malloc(len);
     prop->len = len;
     memcpy(prop->value.bin, bin, len);
 }
Signature · 1 line
1.6.2.2