summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorMiles Bader <miles@lsi.nec.co.jp>2002-07-31 09:44:09 +0000
committerMiles Bader <miles@lsi.nec.co.jp>2002-07-31 09:44:09 +0000
commit3d909b2123af44ad8cc7ae02c099f8a25d00261b (patch)
treedd5ceb3b4e8163f1e22dd7fb3a7990877a23555f /libc/stdlib
parent34067b3b462bb2bbb680575e8b73d7c51e77f56a (diff)
In the allocate-and-copy case, don't include the malloc header in our
size calculations.
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/malloc/realloc.c4
1 files changed, 2 insertions, 2 deletions
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;