From: Hartmut Birr Date: Mon, 1 Apr 2002 22:11:12 +0000 (+0000) Subject: Fixed a wrong parameter for a call to ZwFreeVirtualMemory(). This fixes a page fault... X-Git-Tag: backups/mpw@12443~130 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=b17ab99f15321112539853b4b36b29fb0b418daf Fixed a wrong parameter for a call to ZwFreeVirtualMemory(). This fixes a page fault at address 0 (cr2 = 0). Fixed the calculation of the maximum heap count in RtlInitializeHeapManager(). svn path=/trunk/; revision=2812 --- diff --git a/reactos/lib/ntdll/rtl/heap.c b/reactos/lib/ntdll/rtl/heap.c index 97e3b456d75..0504c3ca3bc 100644 --- a/reactos/lib/ntdll/rtl/heap.c +++ b/reactos/lib/ntdll/rtl/heap.c @@ -461,9 +461,10 @@ static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena, subheap->magic = 0; if (!(flags & HEAP_NO_VALLOC)) { + ULONG dummySize = 0; ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID*)&subheap, - 0, + &dummySize, MEM_RELEASE); } return; @@ -622,9 +623,10 @@ static SUBHEAP *HEAP_CreateSubHeap(PVOID BaseAddress, { if (!(flags & HEAP_NO_VALLOC)) { + ULONG dummySize = 0; ZwFreeVirtualMemory(NtCurrentProcess(), address, - 0, + &dummySize, MEM_RELEASE); return NULL; } @@ -940,11 +942,15 @@ static BOOL HEAP_IsRealArena( + sizeof(ARENA_INUSE))) { if (quiet == NOISY) + { ERR("Heap %08lx: block %08lx is not inside heap\n", (DWORD)heap, (DWORD)block ); + } else if (WARN_ON(heap)) + { WARN("Heap %08lx: block %08lx is not inside heap\n", (DWORD)heap, (DWORD)block ); + } ret = FALSE; } else ret = HEAP_ValidateInUseArena( subheap, (ARENA_INUSE *)block - 1, quiet ); @@ -1064,9 +1070,10 @@ RtlDestroyHeap(HANDLE heap) /* [in] Handle of heap */ if (!(heapPtr->flags & HEAP_NO_VALLOC)) { + ULONG dummySize = 0; ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID*)&subheap, - 0, + &dummySize, MEM_RELEASE); } subheap = next; @@ -1557,7 +1564,7 @@ RtlInitializeHeapManager(VOID) Peb = NtCurrentPeb(); Peb->NumberOfHeaps = 0; - Peb->MaximumNumberOfHeaps = (PAGESIZE - sizeof(PPEB)) / sizeof(HANDLE); + Peb->MaximumNumberOfHeaps = (PAGESIZE - sizeof(PEB)) / sizeof(HANDLE); Peb->ProcessHeaps = (PVOID)Peb + sizeof(PEB); RtlInitializeCriticalSection(&RtlpProcessHeapsListLock);