From 6785250f8c052371abe156dd43eadef47ebf3a46 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 29 May 2019 06:31:28 +0200 Subject: [PATCH] LibC: realloc() should reuse the existing allocation more often. We were only reusing the existing allocation if the new requested size was exactly the same as the fudged size of the block. This meant that realloc() could allocate a new block even though the new block would be identical to the old block. --- LibC/malloc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibC/malloc.cpp b/LibC/malloc.cpp index 9353f4c289..6f456140b9 100644 --- a/LibC/malloc.cpp +++ b/LibC/malloc.cpp @@ -287,7 +287,7 @@ void* realloc(void* ptr, size_t size) auto* header = (const CommonHeader*)page_base; old_size = header->m_size; - if (size == old_size) + if (malloc_good_size(size) == old_size) return ptr; auto* new_ptr = malloc(size); memcpy(new_ptr, ptr, min(old_size, size));