mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 11:00:29 +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
Notes:
sideshowbarker
2024-07-18 17:12:13 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/ea33e9647be Pull-request: https://github.com/SerenityOS/serenity/pull/7555
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…
Reference in a new issue