From ac165f4522adce39e471f2dc4b3fc812f8c8892f Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 25 Mar 2011 10:45:39 -0600 Subject: [PATCH] xmalloc: revert yesterday's regression * lib/xmalloc.c (xrealloc): Once again forward xrealloc(NULL,0) to realloc's underlying behavior (allowing allocation of zero-size objects, especially if malloc-gnu is also in use). Signed-off-by: Eric Blake --- ChangeLog | 7 +++++++ lib/xmalloc.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index eba7d4e4c..c6c969091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-25 Eric Blake + + xmalloc: revert yesterday's regression + * lib/xmalloc.c (xrealloc): Once again forward xrealloc(NULL,0) to + realloc's underlying behavior (allowing allocation of zero-size + objects, especially if malloc-gnu is also in use). + 2011-03-25 Reuben Thomas maint.mk: add missing version to VC-tag diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 4589e7d74..08c30fb8a 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -52,7 +52,7 @@ xmalloc (size_t n) void * xrealloc (void *p, size_t n) { - if (!n) + if (!n && p) { /* The GNU and C99 realloc behaviors disagree here. Act like GNU, even if the underlying realloc is C99. */ @@ -61,7 +61,7 @@ xrealloc (void *p, size_t n) } p = realloc (p, n); - if (!p) + if (!p && n) xalloc_die (); return p; } -- 2.11.0