qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix qemu_realloc()
@ 2009-02-10 12:57 Kevin Wolf
  2009-02-11 21:02 ` Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Wolf @ 2009-02-10 12:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf

For qemu_realloc with size == 0 a result of NULL is perfectly fine

Signed-off-by: Kevin Wolf <kwolf@suse.de>
---
 qemu-malloc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/qemu-malloc.c b/qemu-malloc.c
index e9e49cb..6761857 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -48,7 +48,10 @@ void *qemu_malloc(size_t size)
 
 void *qemu_realloc(void *ptr, size_t size)
 {
-    return oom_check(realloc(ptr, size));
+    if (size)
+        return oom_check(realloc(ptr, size));
+    else
+        return realloc(ptr, size);
 }
 
 void *qemu_mallocz(size_t size)
-- 
1.6.0.2

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

* Re: [Qemu-devel] [PATCH] Fix qemu_realloc()
  2009-02-10 12:57 [Qemu-devel] [PATCH] Fix qemu_realloc() Kevin Wolf
@ 2009-02-11 21:02 ` Anthony Liguori
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2009-02-11 21:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf

Kevin Wolf wrote:
> For qemu_realloc with size == 0 a result of NULL is perfectly fine
>
> Signed-off-by: Kevin Wolf <kwolf@suse.de>
>   

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>  qemu-malloc.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-malloc.c b/qemu-malloc.c
> index e9e49cb..6761857 100644
> --- a/qemu-malloc.c
> +++ b/qemu-malloc.c
> @@ -48,7 +48,10 @@ void *qemu_malloc(size_t size)
>  
>  void *qemu_realloc(void *ptr, size_t size)
>  {
> -    return oom_check(realloc(ptr, size));
> +    if (size)
> +        return oom_check(realloc(ptr, size));
> +    else
> +        return realloc(ptr, size);
>  }
>  
>  void *qemu_mallocz(size_t size)
>   

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

end of thread, other threads:[~2009-02-11 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-10 12:57 [Qemu-devel] [PATCH] Fix qemu_realloc() Kevin Wolf
2009-02-11 21:02 ` Anthony Liguori

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).