From afa6f05e2e0d784250ab6408ff13152920d74495 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 29 May 2009 15:30:57 +0100 Subject: [PATCH] Correctly handle malloc/realloc(0) - malloc and realloc(0) are valid requests. Some implementations may return NULL for these, which would not indicate an error. --- src/guestfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/guestfs.c b/src/guestfs.c index fb214c5..c5056d4 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -418,7 +418,7 @@ void * guestfs_safe_malloc (guestfs_h *g, size_t nbytes) { void *ptr = malloc (nbytes); - if (!ptr) g->abort_cb (); + if (nbytes > 0 && !ptr) g->abort_cb (); return ptr; } @@ -426,7 +426,7 @@ void * guestfs_safe_realloc (guestfs_h *g, void *ptr, int nbytes) { void *p = realloc (ptr, nbytes); - if (!p) g->abort_cb (); + if (nbytes > 0 && !p) g->abort_cb (); return p; } -- 1.8.3.1