From 8bd57b191035bf02b676e2fa760d3a981bd1df02 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Wed, 23 Jan 2013 10:55:14 +0000 Subject: [PATCH] realloc: Set the HEAP when splitting a block Failure to do so means we may put a free block in some random location because ARENA_HEAP_GET() can return something invalid when used to find the correct free list in __free_block(). This bug manifested as running out of available free memory. Cc: H. Peter Anvin Signed-off-by: Matt Fleming --- core/mem/malloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/mem/malloc.c b/core/mem/malloc.c index 02e60614..3825f2a6 100644 --- a/core/mem/malloc.c +++ b/core/mem/malloc.c @@ -165,6 +165,8 @@ __export void *realloc(void *ptr, size_t size) ARENA_TYPE_SET(nah->a.attrs, ARENA_TYPE_FREE); ARENA_SIZE_SET(nah->a.attrs, xsize - newsize); ARENA_SIZE_SET(ah->a.attrs, newsize); + ARENA_HEAP_SET(nah->a.attrs, ARENA_HEAP_GET(ah->a.attrs)); + //nah->a.type = ARENA_TYPE_FREE; //nah->a.size = xsize - newsize; //ah->a.size = newsize; -- 2.11.4.GIT