do not pass NULL to strdup.

Also use qemu_strdup() instead of strdup() in bootindex code.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Gleb Natapov 2011-02-02 17:34:34 +02:00 committed by Aurelien Jarno
parent 72902672dc
commit 4fef930af8

4
vl.c
View File

@ -738,7 +738,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
node = qemu_mallocz(sizeof(FWBootEntry)); node = qemu_mallocz(sizeof(FWBootEntry));
node->bootindex = bootindex; node->bootindex = bootindex;
node->suffix = strdup(suffix); node->suffix = suffix ? qemu_strdup(suffix) : NULL;
node->dev = dev; node->dev = dev;
QTAILQ_FOREACH(i, &fw_boot_order, link) { QTAILQ_FOREACH(i, &fw_boot_order, link) {
@ -785,7 +785,7 @@ char *get_boot_devices_list(uint32_t *size)
} else if (devpath) { } else if (devpath) {
bootpath = devpath; bootpath = devpath;
} else { } else {
bootpath = strdup(i->suffix); bootpath = qemu_strdup(i->suffix);
assert(bootpath); assert(bootpath);
} }