Bladeren bron

Fix dxilconv crash when initialization fails (#3172)

When dxilconv initialization fails in InitMaybeFail (for example under
memory pressure) the malloc references are null yet DxcClearThreadMalloc
is called expecting non-null references.

Adds nullptr checks to DxcClearThreadMalloc before erasing and releasing
the allocators.
Helena Kotas 4 jaren geleden
bovenliggende
commit
4ee59f6c2d
1 gewijzigde bestanden met toevoegingen van 6 en 3 verwijderingen
  1. 6 3
      lib/DxcSupport/dxcmem.cpp

+ 6 - 3
lib/DxcSupport/dxcmem.cpp

@@ -58,10 +58,13 @@ IMalloc *DxcGetThreadMallocNoRef() throw() {
 }
 
 void DxcClearThreadMalloc() throw() {
-  DXASSERT(g_ThreadMallocTls != nullptr, "else prior to DxcInitThreadMalloc or after DxcCleanupThreadMalloc");
   IMalloc *pMalloc = DxcGetThreadMallocNoRef();
-  g_ThreadMallocTls->erase();
-  pMalloc->Release();
+  if (g_ThreadMallocTls != nullptr) {
+    g_ThreadMallocTls->erase();
+  }
+  if (pMalloc != nullptr) {
+    pMalloc->Release();
+  }
 }
 
 void DxcSetThreadMallocToDefault() throw() {