Browse Source

(realloc): Record the correct size in the malloc header in the case
where we extended the existing allocation, and got back more than we
asked for from the heap.

Miles Bader 24 years ago
parent
commit
5752e10795
1 changed files with 1 additions and 1 deletions
  1. 1 1
      libc/stdlib/malloc/realloc.c

+ 1 - 1
libc/stdlib/malloc/realloc.c

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