xmalloc: revert yesterday's regression
authorEric Blake <eblake@redhat.com>
Fri, 25 Mar 2011 16:45:39 +0000 (10:45 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 25 Mar 2011 16:45:39 +0000 (10:45 -0600)
* 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 <eblake@redhat.com>
ChangeLog
lib/xmalloc.c

index eba7d4e..c6c9690 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-03-25  Eric Blake  <eblake@redhat.com>
+
+       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  <rrt@sc3d.org>
 
        maint.mk: add missing version to VC-tag
index 4589e7d..08c30fb 100644 (file)
@@ -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;
 }