summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibC/malloc.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibC/malloc.cpp b/Userland/Libraries/LibC/malloc.cpp
index 7e57612db5..3331537293 100644
--- a/Userland/Libraries/LibC/malloc.cpp
+++ b/Userland/Libraries/LibC/malloc.cpp
@@ -437,8 +437,10 @@ void* realloc(void* ptr, size_t size)
{
if (!ptr)
return malloc(size);
- if (!size)
+ if (!size) {
+ free(ptr);
return nullptr;
+ }
Threading::Locker locker(malloc_lock());
auto existing_allocation_size = malloc_size(ptr);