Patchwork [3/5] qdev: don't crash on unset drive properties.

login
register
mail settings
Submitter Gerd Hoffmann
Date Sept. 16, 2009, 8:25 p.m.
Message ID <1253132744-10492-4-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/33736/
State Superseded
Headers show

Comments

Gerd Hoffmann - Sept. 16, 2009, 8:25 p.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev-properties.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 2ecb58d..edacf35 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -180,7 +180,7 @@  static int parse_drive(DeviceState *dev, Property *prop, const char *str)
 static int print_drive(DeviceState *dev, Property *prop, char *dest, size_t len)
 {
     DriveInfo **ptr = qdev_get_prop_ptr(dev, prop);
-    return snprintf(dest, len, "%s", (*ptr)->id);
+    return snprintf(dest, len, "%s", (*ptr) ? (*ptr)->id : "<null>");
 }
 
 PropertyInfo qdev_prop_drive = {