summaryrefslogtreecommitdiff
path: root/realloc.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2003-02-11 09:44:19 +0100
committerNiels Möller <nisse@lysator.liu.se>2003-02-11 09:44:19 +0100
commit27889a95d9c49a8121ebc896efc650db86402444 (patch)
treeed71eae4e36d40c7b2dc37feac9c00e5361af685 /realloc.c
parent766de8e43d35b574e20695d85915d18fca3db29d (diff)
downloadnettle-27889a95d9c49a8121ebc896efc650db86402444.tar.gz
(nettle_xrealloc): Fixed out-of-memory check.
Rev: src/nettle/realloc.c:1.2
Diffstat (limited to 'realloc.c')
-rw-r--r--realloc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/realloc.c b/realloc.c
index 421abe88..59500dfa 100644
--- 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;
}