diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c index 17bc6ceab3a..3fd54ddfcbb 100644 --- a/dlls/ntdll/critsection.c +++ b/dlls/ntdll/critsection.c @@ -74,18 +74,22 @@ static inline HANDLE get_semaphore( RTL_CRITICAL_SECTION *crit ) */ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit ) { - crit->DebugInfo = RtlAllocateHeap(ntdll_get_process_heap(), 0, sizeof(CRITICAL_SECTION_DEBUG)); - if (crit->DebugInfo) + if (!ntdll_get_process_heap()) crit->DebugInfo = NULL; + else { - crit->DebugInfo->Type = 0; - crit->DebugInfo->CreatorBackTraceIndex = 0; - crit->DebugInfo->CriticalSection = crit; - crit->DebugInfo->ProcessLocksList.Blink = &(crit->DebugInfo->ProcessLocksList); - crit->DebugInfo->ProcessLocksList.Flink = &(crit->DebugInfo->ProcessLocksList); - crit->DebugInfo->EntryCount = 0; - crit->DebugInfo->ContentionCount = 0; - crit->DebugInfo->Spare[0] = 0; - crit->DebugInfo->Spare[1] = 0; + crit->DebugInfo = RtlAllocateHeap(ntdll_get_process_heap(), 0, sizeof(CRITICAL_SECTION_DEBUG)); + if (crit->DebugInfo) + { + crit->DebugInfo->Type = 0; + crit->DebugInfo->CreatorBackTraceIndex = 0; + crit->DebugInfo->CriticalSection = crit; + crit->DebugInfo->ProcessLocksList.Blink = &(crit->DebugInfo->ProcessLocksList); + crit->DebugInfo->ProcessLocksList.Flink = &(crit->DebugInfo->ProcessLocksList); + crit->DebugInfo->EntryCount = 0; + crit->DebugInfo->ContentionCount = 0; + crit->DebugInfo->Spare[0] = 0; + crit->DebugInfo->Spare[1] = 0; + } } crit->LockCount = -1; crit->RecursionCount = 0;