summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@lsi.nec.co.jp>2002-07-31 02:10:52 +0000
committerMiles Bader <miles@lsi.nec.co.jp>2002-07-31 02:10:52 +0000
commit73900d95a7ba128d004783a5a3646c6137bf9361 (patch)
tree2bd7fa42033114d1f1e1c26b162f0a22e0f782e0
parentdef04f26ab3c9c17d0b4b4dacf83008d265625a7 (diff)
Account for MALLOC_HEADER_SIZE when calculating new size.
-rw-r--r--libc/stdlib/malloc/realloc.c7
1 files changed, 4 insertions, 3 deletions
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);