bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xmalloc: revert yesterday's regression


From: Eric Blake
Subject: [PATCH] xmalloc: revert yesterday's regression
Date: Fri, 25 Mar 2011 10:50:39 -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 <address@hidden>
---
 ChangeLog     |    7 +++++++
 lib/xmalloc.c |    4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eba7d4e..c6c9690 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-03-25  Eric Blake  <address@hidden>
+
+       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  <address@hidden>

        maint.mk: add missing version to VC-tag
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 4589e7d..08c30fb 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;
 }
-- 
1.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]