summaryrefslogtreecommitdiffstats
path: root/src/guestfs.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-05-29 15:30:57 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-05-29 15:30:57 +0100
commitafa6f05e2e0d784250ab6408ff13152920d74495 (patch)
tree7e8098d439f1d016fa36dcc3b41bd5d6f1d93a92 /src/guestfs.c
parent80c5acfd148ede4ec1ca2dc2330b043b0cea29d5 (diff)
downloadlibguestfs-afa6f05e2e0d784250ab6408ff13152920d74495.tar.gz
libguestfs-afa6f05e2e0d784250ab6408ff13152920d74495.tar.xz
libguestfs-afa6f05e2e0d784250ab6408ff13152920d74495.zip
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.
Diffstat (limited to 'src/guestfs.c')
-rw-r--r--src/guestfs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/guestfs.c b/src/guestfs.c
index fb214c53..c5056d44 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;
}