From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MA7Dl-0002KB-II for qemu-devel@nongnu.org; Fri, 29 May 2009 14:54:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MA7Dg-0002D1-U1 for qemu-devel@nongnu.org; Fri, 29 May 2009 14:54:25 -0400 Received: from [199.232.76.173] (port=33790 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MA7Dg-0002Co-JQ for qemu-devel@nongnu.org; Fri, 29 May 2009 14:54:20 -0400 Received: from mx2.redhat.com ([66.187.237.31]:52005) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MA7Dg-0001lm-1T for qemu-devel@nongnu.org; Fri, 29 May 2009 14:54:20 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4TIsJkr028871 for ; Fri, 29 May 2009 14:54:19 -0400 From: Gerd Hoffmann Date: Fri, 29 May 2009 20:54:16 +0200 Message-Id: <1243623256-7928-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH] qdev: uglify qdev_set_prop_bin() to deal with qemu_malloc(0) aborting. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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 --- 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