OSDN Git Service

(realloc): Record the correct size in the malloc header in the case
authorMiles Bader <miles@lsi.nec.co.jp>
Mon, 9 Sep 2002 07:40:07 +0000 (07:40 -0000)
committerMiles Bader <miles@lsi.nec.co.jp>
Mon, 9 Sep 2002 07:40:07 +0000 (07:40 -0000)
where we extended the existing allocation, and got back more than we
asked for from the heap.

libc/stdlib/malloc/realloc.c

index db26866..e4c8ad7 100644 (file)
@@ -57,7 +57,7 @@ realloc (void *mem, size_t new_size)
 
       if (extra)
        /* Record the changed size.  */
-       MALLOC_SET_SIZE (base_mem, new_size);
+       MALLOC_SET_SIZE (base_mem, size + extra);
       else
        /* Our attempts to extend MEM in place failed, just
           allocate-and-copy.  */