qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix qemu_malloc.
Date: Mon, 26 Jan 2009 11:43:27 +0100	[thread overview]
Message-ID: <497D93CF.6030705@redhat.com> (raw)

[-- 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


                 reply	other threads:[~2009-01-26 18:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=497D93CF.6030705@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).