mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
LibC: Don't leak memory for realloc(p, 0)
Previously we'd leak memory when the user called realloc(p, 0). Instead this call should behave as if the user had called free(p).
This commit is contained in:
parent
3ece67d62d
commit
ea33e9647b
1 changed files with 3 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue