diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-05-29 15:30:57 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-05-29 15:30:57 +0100 |
commit | afa6f05e2e0d784250ab6408ff13152920d74495 (patch) | |
tree | 7e8098d439f1d016fa36dcc3b41bd5d6f1d93a92 /src/guestfs.c | |
parent | 80c5acfd148ede4ec1ca2dc2330b043b0cea29d5 (diff) | |
download | libguestfs-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.c | 4 |
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; } |