qdev: don't crash on unset drive properties.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Gerd Hoffmann 2009-09-22 13:53:20 +02:00 committed by Anthony Liguori
parent 99244fa151
commit 41b5e892b7
1 changed files with 1 additions and 1 deletions

View File

@ -208,7 +208,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 = {