diff options
author | Mike Frysinger <vapier@gentoo.org> | 2007-04-24 05:24:08 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2007-04-24 05:24:08 +0000 |
commit | 086ca312f1450664bce2746085725fe144897d70 (patch) | |
tree | 8793ad35857ed5026b93ec943438ceda9ad9560d /libc | |
parent | 607f5bc303a598e804d6e4c58f67e2c33030edc3 (diff) |
fix from Bernd Schmidt for realloc shrinkage bug
Diffstat (limited to 'libc')
-rw-r--r-- | libc/stdlib/malloc/realloc.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index 21ff9a37f..ec57b874e 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -46,6 +46,11 @@ realloc (void *mem, size_t new_size) allocation unit (SIZE is already guaranteed to be so).*/ new_size = HEAP_ADJUST_SIZE (new_size + MALLOC_HEADER_SIZE); + if (new_size < sizeof (struct heap_free_area)) + /* Because we sometimes must use a freed block to hold a free-area node, + we must make sure that every allocated block can hold one. */ + new_size = HEAP_ADJUST_SIZE (sizeof (struct heap_free_area)); + MALLOC_DEBUG (1, "realloc: 0x%lx, %d (base = 0x%lx, total_size = %d)", (long)mem, new_size, (long)base_mem, size); |