diff options
author | malc <av1474@comtv.ru> | 2009-05-19 22:26:42 +0400 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2009-05-19 22:29:15 +0400 |
commit | a7d27b536ffc0773028a90f14580552c0c3ddb2a (patch) | |
tree | f8b5e3da0a779d0907ce8340d88d4b23e8648c9e /qemu-malloc.c | |
parent | 20094efc194169ab9d37c28a9b0c8c8653b7e535 (diff) |
Abort on attempts to allocate zero bytes
http://marc.info/?t=124267873300015&r=1&w=2
Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'qemu-malloc.c')
-rw-r--r-- | qemu-malloc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/qemu-malloc.c b/qemu-malloc.c index 676185786c..5e9f47f518 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) |