ceil-ieee tests: More tests.
[gnulib.git] / lib / xmalloc.c
index 4589e7d..3b5f86c 100644 (file)
@@ -1,6 +1,6 @@
 /* xmalloc.c -- malloc with out of memory checking
 
-   Copyright (C) 1990-2000, 2002-2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 1990-2000, 2002-2006, 2008-2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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;
 }