From 73900d95a7ba128d004783a5a3646c6137bf9361 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 31 Jul 2002 02:10:52 +0000 Subject: Account for MALLOC_HEADER_SIZE when calculating new size. --- libc/stdlib/malloc/realloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libc/stdlib/malloc/realloc.c') diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index e8906422d..4372751d0 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -28,9 +28,10 @@ realloc (void *mem, size_t new_size) char *base_mem = MALLOC_BASE (mem); size_t size = MALLOC_SIZE (mem); - /* Make sure that we're dealing in a multiple of the heap allocation - unit (SIZE is already guaranteed to be so). */ - new_size = HEAP_ADJUST_SIZE (new_size); + /* Include extra space to record the size of the allocated block. + Also make sure that we're dealing in a multiple of the heap + allocation unit (SIZE is already guaranteed to be so).*/ + new_size = HEAP_ADJUST_SIZE (new_size + MALLOC_HEADER_SIZE); MALLOC_DEBUG ("realloc: 0x%lx, %d (base = 0x%lx, total_size = %d)\n", (long)mem, new_size, (long)base_mem, size); -- cgit v1.2.3