Commit 3f52b3a7 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

ntdll: Correctly free pending pointer in RtlDestroyHeap.

It's allocated from the heap itself, should be freed even for the main process heap, and before destroying the CS or notifying valgrind of used block being freed. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com>
parent e4e8cabf
......@@ -1431,6 +1431,7 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap )
HEAP *heapPtr = HEAP_GetPtr( heap );
SUBHEAP *subheap, *next;
ARENA_LARGE *arena, *arena_next;
struct block **pending, **tmp;
SIZE_T size;
void *addr;
......@@ -1443,6 +1444,15 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap )
}
if (!heapPtr) return heap;
if ((pending = heapPtr->pending_free))
{
heapPtr->pending_free = NULL;
for (tmp = pending; *tmp && tmp != pending + MAX_FREE_PENDING; ++tmp)
if ((subheap = find_subheap( heap, *tmp, FALSE )))
free_used_block( subheap, *tmp );
RtlFreeHeap( heap, 0, pending );
}
if (heap == processHeap) return heap; /* cannot delete the main process heap */
/* remove it from the per-process list */
......@@ -1470,7 +1480,6 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap )
NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE );
}
notify_free_all( &heapPtr->subheap );
RtlFreeHeap( GetProcessHeap(), 0, heapPtr->pending_free );
size = 0;
addr = heap;
NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment