From a5cf8262e4eb9c4646434e2c6211ef8608db3233 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 4 Oct 2012 13:09:44 +0200 Subject: scsi, pci, qdev, isa-bus, sysbus: don't let *_get_fw_dev_path return NULL Use g_strdup rather than strdup, because the sole caller (qdev_get_fw_dev_path_helper) assumes it gets non-NULL, and dereferences it. Besides, in that caller, the allocated buffer is already freed with g_free, so it's better to allocate with a matching g_strdup. In one case, (scsi-bus.c) it was trivial, so I replaced an snprintf+ g_strdup combination with an equivalent g_strdup_printf use. Signed-off-by: Jim Meyering Signed-off-by: Anthony Liguori --- hw/isa-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/isa-bus.c') diff --git a/hw/isa-bus.c b/hw/isa-bus.c index f9b237387a..47c93d37b6 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -236,7 +236,7 @@ static char *isabus_get_fw_dev_path(DeviceState *dev) snprintf(path + off, sizeof(path) - off, "@%04x", d->ioport_id); } - return strdup(path); + return g_strdup(path); } MemoryRegion *isa_address_space(ISADevice *dev) -- cgit v1.2.1