From d78755e2b5b13339a6f2f78e0c426ea4cba5b542 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sun, 29 Mar 2015 14:10:20 +0000 Subject: [PATCH] [RTL] - HEAP_ENTRY::Size is in bytes for HEAP_ENTRY_VIRTUAL_ALLOC allocations. Save it accordingly CORE-9441 svn path=/trunk/; revision=66959 --- reactos/lib/rtl/heap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/lib/rtl/heap.c b/reactos/lib/rtl/heap.c index f82b39c78a8..80be5bd3c58 100644 --- a/reactos/lib/rtl/heap.c +++ b/reactos/lib/rtl/heap.c @@ -427,6 +427,7 @@ RtlpGetSizeOfBigBlock(PHEAP_ENTRY HeapEntry) /* Get pointer to the containing record */ VirtualEntry = CONTAINING_RECORD(HeapEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); + ASSERT(VirtualEntry->BusyBlock.Size >= sizeof(HEAP_VIRTUAL_ALLOC_ENTRY)); /* Restore the real size */ return VirtualEntry->CommitSize - HeapEntry->Size; @@ -2096,6 +2097,7 @@ RtlAllocateHeap(IN PVOID HeapPtr, /* Initialize the newly allocated block */ VirtualBlock->BusyBlock.Size = (USHORT)(AllocationSize - Size); + ASSERT(VirtualBlock->BusyBlock.Size >= sizeof(HEAP_VIRTUAL_ALLOC_ENTRY)); VirtualBlock->BusyBlock.Flags = EntryFlags | HEAP_ENTRY_VIRTUAL_ALLOC | HEAP_ENTRY_EXTRA_PRESENT; VirtualBlock->CommitSize = AllocationSize; VirtualBlock->ReserveSize = AllocationSize; @@ -2648,7 +2650,8 @@ RtlReAllocateHeap(HANDLE HeapPtr, if (InUseEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) { /* Simple in case of a virtual alloc - just an unused size */ - InUseEntry->Size = (USHORT)((AllocationSize - Size) >> HEAP_ENTRY_SHIFT); + InUseEntry->Size = (USHORT)(AllocationSize - Size); + ASSERT(InUseEntry->Size >= sizeof(HEAP_VIRTUAL_ALLOC_ENTRY)); } else if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) {