summaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/wrapper.c b/wrapper.c
index 4ff4a9c3db..bcda41e374 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -117,10 +117,13 @@ void *xrealloc(void *ptr, size_t size)
{
void *ret;
+ if (!size) {
+ free(ptr);
+ return xmalloc(0);
+ }
+
memory_limit_check(size, 0);
ret = realloc(ptr, size);
- if (!ret && !size)
- ret = realloc(ptr, 1);
if (!ret)
die("Out of memory, realloc failed");
return ret;