From c5207489fd00b387e878a372d49f11a4c6bd4468 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 8 Nov 2013 10:31:57 -0800 Subject: [PATCH] fix(memory): realloc must behave like malloc when ptr is nullptr Signed-off-by: Leonardo de Moura --- src/util/memory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/memory.cpp b/src/util/memory.cpp index 4f5ebdad5..b8e9ce884 100644 --- a/src/util/memory.cpp +++ b/src/util/memory.cpp @@ -137,6 +137,8 @@ void * malloc(size_t sz) { } void * realloc(void * ptr, size_t sz) { + if (ptr == nullptr) + return malloc(sz); size_t old_sz = malloc_size(ptr); g_global_memory.dec(old_sz); g_thread_memory.dec(old_sz);