]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(nettle_xrealloc): Fixed out-of-memory check.
authorNiels Möller <nisse@lysator.liu.se>
Tue, 11 Feb 2003 08:44:19 +0000 (09:44 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 11 Feb 2003 08:44:19 +0000 (09:44 +0100)
Rev: src/nettle/realloc.c:1.2

realloc.c

index 421abe887ef53df9f6df8562d798b7ddb747e055..59500dfa7e390da640691782c6c2716eeda72b7b 100644 (file)
--- a/realloc.c
+++ b/realloc.c
@@ -41,9 +41,10 @@ void *
 nettle_xrealloc(void *ctx UNUSED, void *p, unsigned length)
 {
   void *n = realloc(p, length);
-  if (n)
-    return n;
-
-  fprintf(stderr, "Virtual memory exhausted.\n");
-  abort();    
+  if (length && !n)
+    {
+      fprintf(stderr, "Virtual memory exhausted.\n");
+      abort();
+    }
+  return n;
 }