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

Submitted by Gerd Hoffmann on Sept. 16, 2009, 8:25 p.m.

Details

Message ID 1253132744-10492-4-git-send-email-kraxel@redhat.com
State Superseded
Headers show

Commit Message

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 hide | download patch | download mbox

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 = {