diff options
author | malc <malc@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-01-28 17:16:56 +0000 |
---|---|---|
committer | malc <malc@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-01-28 17:16:56 +0000 |
commit | baa8c602295b1d33844503ce0a172b85f84646d3 (patch) | |
tree | 4c4f99ea0f4c9f63845bf692e648fb3a71fc4cf2 | |
parent | 480b9f24d75eb8fcd25ead73b6f0265b08218c5e (diff) |
Fix qemu_malloc.
make {linux,bsd}-user qemu_realloc handle ptr == NULL correctly.
spotted by malc.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6466 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r-- | bsd-user/mmap.c | 2 | ||||
-rw-r--r-- | linux-user/mmap.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 66233abc11..e916a6544e 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -127,6 +127,8 @@ void *qemu_realloc(void *ptr, size_t size) size_t old_size, copy; void *new_ptr; + if (!ptr) + return qemu_malloc(size); old_size = *(size_t *)((char *)ptr - 16); copy = old_size < size ? old_size : size; new_ptr = qemu_malloc(size); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d0fc3e3d1a..888b491403 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -128,6 +128,8 @@ void *qemu_realloc(void *ptr, size_t size) size_t old_size, copy; void *new_ptr; + if (!ptr) + return qemu_malloc(size); old_size = *(size_t *)((char *)ptr - 16); copy = old_size < size ? old_size : size; new_ptr = qemu_malloc(size); |