Skip to contentSkip to conversation

Fix qemu_malloc.

PATCH New Gerd Hoffmann 1 participant 1 message Jan 26, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix qemu_malloc.

bug spotted by malc.

please apply,
Gerd

Quoted 1 line

From 42105a6e8e4969c8f8b683d541a38c4de0e4631f Mon Sep 17 00:00:00 2001

From: Gerd Hoffmann <[email protected]>
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.

---
 linux-user/mmap.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
linux-user/mmap.c +2 -0
index d0fc3e3..888b491 100644
@@ -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);
Signature · 1 line
1.6.1