]> mj.ucw.cz Git - libucw.git/commitdiff
LibUCW: xrealloc(ptr, 0) should return NULL and not die.
authorPavel Charvat <pchar@ucw.cz>
Thu, 28 Nov 2013 12:09:47 +0000 (13:09 +0100)
committerPavel Charvat <pchar@ucw.cz>
Thu, 28 Nov 2013 12:09:47 +0000 (13:09 +0100)
ucw/realloc.c

index 3f2eff2bbf6c94189584f38f4a89ac7b3235d1b0..4a15e3aacc863b14e2dc2b3c29facad2e140eedb 100644 (file)
@@ -16,7 +16,7 @@ xrealloc(void *old, size_t size)
 {
   /* We assume that realloc(NULL, x) works like malloc(x), which is true with the glibc. */
   void *x = realloc(old, size);
-  if (!x)
+  if (!x && size)
     die("Cannot reallocate %zu bytes of memory", size);
   return x;
 }