qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [6466] Fix qemu_malloc.
@ 2009-01-28 17:16 malc
  2009-01-28 18:44 ` [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc() Pavel Vasilyev
  0 siblings, 1 reply; 4+ messages in thread
From: malc @ 2009-01-28 17:16 UTC (permalink / raw)
  To: qemu-devel

Revision: 6466
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6466
Author:   malc
Date:     2009-01-28 17:16:56 +0000 (Wed, 28 Jan 2009)

Log Message:
-----------
Fix qemu_malloc.

make {linux,bsd}-user qemu_realloc handle ptr == NULL correctly.
spotted by malc.

Modified Paths:
--------------
    trunk/bsd-user/mmap.c
    trunk/linux-user/mmap.c

Modified: trunk/bsd-user/mmap.c
===================================================================
--- trunk/bsd-user/mmap.c	2009-01-27 19:15:31 UTC (rev 6465)
+++ trunk/bsd-user/mmap.c	2009-01-28 17:16:56 UTC (rev 6466)
@@ -127,6 +127,8 @@
     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);

Modified: trunk/linux-user/mmap.c
===================================================================
--- trunk/linux-user/mmap.c	2009-01-27 19:15:31 UTC (rev 6465)
+++ trunk/linux-user/mmap.c	2009-01-28 17:16:56 UTC (rev 6466)
@@ -128,6 +128,8 @@
     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);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-28 20:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 17:16 [Qemu-devel] [6466] Fix qemu_malloc malc
2009-01-28 18:44 ` [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc() Pavel Vasilyev
2009-01-28 19:33   ` Lionel Landwerlin
2009-01-28 20:00     ` malc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).