diff options
Diffstat (limited to 'src/vm/hosting.cpp')
-rw-r--r-- | src/vm/hosting.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/vm/hosting.cpp b/src/vm/hosting.cpp index d47bc28238..035fff8812 100644 --- a/src/vm/hosting.cpp +++ b/src/vm/hosting.cpp @@ -480,12 +480,15 @@ BOOL EEHeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) #ifdef _DEBUG GlobalAllocStore::RemoveAlloc (lpMem); - // Check the heap handle to detect heap contamination - lpMem = (BYTE*)lpMem - OS_HEAP_ALIGN; - HANDLE storedHeapHandle = *((HANDLE*)lpMem); - if(storedHeapHandle != hHeap) - _ASSERTE(!"Heap contamination detected! HeapFree was called on a heap other than the one that memory was allocated from.\n" - "Possible cause: you used new (executable) to allocate the memory, but didn't use DeleteExecutable() to free it."); + if (lpMem != NULL) + { + // Check the heap handle to detect heap contamination + lpMem = (BYTE*)lpMem - OS_HEAP_ALIGN; + HANDLE storedHeapHandle = *((HANDLE*)lpMem); + if(storedHeapHandle != hHeap) + _ASSERTE(!"Heap contamination detected! HeapFree was called on a heap other than the one that memory was allocated from.\n" + "Possible cause: you used new (executable) to allocate the memory, but didn't use DeleteExecutable() to free it."); + } #endif // DON'T REMOVE THIS SEEMINGLY USELESS CAST // |