Skip to contentSkip to conversation

do not pass NULL to strdup.

PATCH Applied Gleb Natapov 3 participants 3 messages Feb 2, 2011 – Feb 4, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 do not pass NULL to strdup.

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

---

Should go to stable too.

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

--
Gleb.

#1 lore raw
Quoted 6 lines · Gleb Natapov

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

---

Should go to stable too.

Yes, please! By the way, putting 0.14 in the subject should help with that.

#2 lore raw
In reply to Gleb Natapov
Quoted 6 lines · Gleb Natapov

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

---

Should go to stable too.

Thanks, applied

Quoted 26 lines
vl.c +2 -3
index 655617f..ed2cdfa 100644
@@ -738,7 +738,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
 
     node = qemu_mallocz(sizeof(FWBootEntry));
     node->bootindex = bootindex;
-    node->suffix = strdup(suffix);
+    node->suffix = suffix ? qemu_strdup(suffix) : NULL;
     node->dev = dev;
 
     QTAILQ_FOREACH(i, &fw_boot_order, link) {
@@ -785,7 +785,7 @@ char *get_boot_devices_list(uint32_t *size)
         } else if (devpath) {
             bootpath = devpath;
         } else {
-            bootpath = strdup(i->suffix);
+            bootpath = qemu_strdup(i->suffix);
             assert(bootpath);
         }
 
--

Gleb.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net