Skip to contentSkip to conversation

Fix qemu_realloc()

PATCH Applied Kevin Wolf 2 participants 2 messages Feb 10, 2009 – Feb 11, 2009

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 Fix qemu_realloc()

For qemu_realloc with size == 0 a result of NULL is perfectly fine

---
 qemu-malloc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
qemu-malloc.c +4 -1
index e9e49cb..6761857 100644
@@ -48,7 +48,10 @@ void *qemu_malloc(size_t size)
 
 void *qemu_realloc(void *ptr, size_t size)
 {
-    return oom_check(realloc(ptr, size));
+    if (size)
+        return oom_check(realloc(ptr, size));
+    else
+        return realloc(ptr, size);
 }
 
 void *qemu_mallocz(size_t size)
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 4 lines · Kevin Wolf

For qemu_realloc with size == 0 a result of NULL is perfectly fine

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 21 lines
---
 qemu-malloc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
qemu-malloc.c +4 -1
index e9e49cb..6761857 100644
@@ -48,7 +48,10 @@ void *qemu_malloc(size_t size)
 
 void *qemu_realloc(void *ptr, size_t size)
 {
-    return oom_check(realloc(ptr, size));
+    if (size)
+        return oom_check(realloc(ptr, size));
+    else
+        return realloc(ptr, size);
 }
 
 void *qemu_mallocz(size_t size)