* [Qemu-devel] [PATCH] Fix qemu_malloc.
@ 2009-01-26 10:43 Gerd Hoffmann
0 siblings, 0 replies; only message in thread
From: Gerd Hoffmann @ 2009-01-26 10:43 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 43 bytes --]
bug spotted by malc.
please apply,
Gerd
[-- Attachment #2: 0004-Fix-qemu_malloc.patch --]
[-- Type: text/plain, Size: 826 bytes --]
>From 42105a6e8e4969c8f8b683d541a38c4de0e4631f Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 26 Jan 2009 11:40:03 +0100
Subject: [PATCH] Fix qemu_malloc.
make linux-user qemu_realloc handle ptr == NULL correctly.
spotted by malc.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
linux-user/mmap.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index d0fc3e3..888b491 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);
--
1.6.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-01-26 18:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-26 10:43 [Qemu-devel] [PATCH] Fix qemu_malloc Gerd Hoffmann
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).