qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [COMMIT a7d27b5] Abort on attempts to allocate zero bytes


From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT a7d27b5] Abort on attempts to allocate zero bytes
Date: Tue, 19 May 2009 18:31:05 -0000

From: malc <address@hidden>

http://marc.info/?t=124267873300015&r=1&w=2

Signed-off-by: malc <address@hidden>

diff --git a/qemu-malloc.c b/qemu-malloc.c
index 6761857..5e9f47f 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -43,6 +43,8 @@ void qemu_free(void *ptr)
 
 void *qemu_malloc(size_t size)
 {
+    if (!size)
+        abort();
     return oom_check(malloc(size));
 }
 
@@ -50,8 +52,11 @@ void *qemu_realloc(void *ptr, size_t size)
 {
     if (size)
         return oom_check(realloc(ptr, size));
-    else
-        return realloc(ptr, size);
+    else {
+        if (ptr)
+            return realloc(ptr, size);
+    }
+    abort();
 }
 
 void *qemu_mallocz(size_t size)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]