From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/heap.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 0a8694704d3..4326199a07b 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -1640,7 +1640,6 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b SIZE_T block_size, SIZE_T size, void **ret ) { SIZE_T old_block_size, old_size; - struct block *next; NTSTATUS status;
if (block_get_flags( block ) & BLOCK_FLAG_LARGE) @@ -1658,17 +1657,12 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b if (block_size > old_block_size) { SUBHEAP *subheap = block_get_subheap( heap, block ); + struct entry *entry; + struct block *next;
- if ((next = next_block( subheap, block )) && (block_get_flags( next ) & BLOCK_FLAG_FREE) && - block_size < HEAP_MIN_LARGE_BLOCK_SIZE && block_size <= old_block_size + block_get_size( next )) - { - /* The next block is free and large enough */ - struct entry *entry = (struct entry *)next; - list_remove( &entry->entry ); - old_block_size += block_get_size( next ); - if (!subheap_commit( heap, subheap, block, block_size )) return STATUS_NO_MEMORY; - } - else + if (!(next = next_block( subheap, block )) || !(block_get_flags( next ) & BLOCK_FLAG_FREE) || + block_size >= HEAP_MIN_LARGE_BLOCK_SIZE || + block_size > old_block_size + block_get_size( next )) { if (flags & HEAP_REALLOC_IN_PLACE_ONLY) return STATUS_NO_MEMORY; if ((status = heap_allocate( heap, flags & ~HEAP_ZERO_MEMORY, block_size, size, ret ))) return status; @@ -1679,6 +1673,12 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b free_used_block( heap, flags, block ); return STATUS_SUCCESS; } + + /* The next block is free and large enough */ + entry = (struct entry *)next; + list_remove( &entry->entry ); + old_block_size += block_get_size( next ); + if (!subheap_commit( heap, subheap, block, block_size )) return STATUS_NO_MEMORY; }
valgrind_notify_resize( block + 1, old_size, size );