From 3d909b2123af44ad8cc7ae02c099f8a25d00261b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 31 Jul 2002 09:44:09 +0000 Subject: In the allocate-and-copy case, don't include the malloc header in our size calculations. --- libc/stdlib/malloc/realloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libc/stdlib/malloc/realloc.c') diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index f19df8bde..f1b78fcbc 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -52,10 +52,10 @@ realloc (void *mem, size_t new_size) /* Our attempts to extend MEM in place failed, just allocate-and-copy. */ { - void *new_mem = malloc (new_size); + void *new_mem = malloc (new_size - MALLOC_HEADER_SIZE); if (new_mem) { - memcpy (new_mem, mem, size); + memcpy (new_mem, mem, size - MALLOC_HEADER_SIZE); free (mem); } mem = new_mem; -- cgit v1.2.3