Commit baa8c602295b1d33844503ce0a172b85f84646d3

Authored by malc
1 parent 480b9f24

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
bsd-user/mmap.c
... ... @@ -127,6 +127,8 @@ void *qemu_realloc(void *ptr, size_t size)
127 127 size_t old_size, copy;
128 128 void *new_ptr;
129 129  
  130 + if (!ptr)
  131 + return qemu_malloc(size);
130 132 old_size = *(size_t *)((char *)ptr - 16);
131 133 copy = old_size < size ? old_size : size;
132 134 new_ptr = qemu_malloc(size);
... ...
linux-user/mmap.c
... ... @@ -128,6 +128,8 @@ void *qemu_realloc(void *ptr, size_t size)
128 128 size_t old_size, copy;
129 129 void *new_ptr;
130 130  
  131 + if (!ptr)
  132 + return qemu_malloc(size);
131 133 old_size = *(size_t *)((char *)ptr - 16);
132 134 copy = old_size < size ? old_size : size;
133 135 new_ptr = qemu_malloc(size);
... ...