qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH] qdev: uglify qdev_set_prop_bin() to deal with qemu_malloc(0) aborting.
Date: Fri, 29 May 2009 20:54:16 +0200	[thread overview]
Message-ID: <1243623256-7928-1-git-send-email-kraxel@redhat.com> (raw)

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

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

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 74a2892..62cff6b 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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);
 }
-- 
1.6.2.2

                 reply	other threads:[~2009-05-29 18:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1243623256-7928-1-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).