From abc3539768182912b95cb4cd36ab1e1f004401b4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 26 Sep 2001 23:11:21 +0000 Subject: [PATCH] Fixed size check in HEAP_FindFreeBlock to make sure we also find blocks that have the exact size needed. --- memory/heap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/memory/heap.c b/memory/heap.c index 8e0015a6426..285ebe2e879 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -614,7 +614,9 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, DWORD size, pArena = pEntry->arena.next; while (pArena != &heap->freeList[0].arena) { - if (pArena->size > size) + DWORD arena_size = (pArena->size & ARENA_SIZE_MASK) + + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE); + if (arena_size >= size) { subheap = HEAP_FindSubHeap( heap, pArena ); if (!HEAP_Commit( subheap, (char *)pArena + sizeof(ARENA_INUSE) @@ -623,7 +625,6 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, DWORD size, *ppSubHeap = subheap; return pArena; } - pArena = pArena->next; }