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);