Browse Source

Fix dxilconv crash when initialization fails (#3254)

Helena Kotas 4 years ago
parent
commit
a39e52dd81
1 changed files with 4 additions and 4 deletions
  1. 4 4
      lib/DxcSupport/dxcmem.cpp

+ 4 - 4
lib/DxcSupport/dxcmem.cpp

@@ -58,12 +58,12 @@ IMalloc *DxcGetThreadMallocNoRef() throw() {
 }
 }
 
 
 void DxcClearThreadMalloc() throw() {
 void DxcClearThreadMalloc() throw() {
-  IMalloc *pMalloc = DxcGetThreadMallocNoRef();
   if (g_ThreadMallocTls != nullptr) {
   if (g_ThreadMallocTls != nullptr) {
+    IMalloc *pMalloc = DxcGetThreadMallocNoRef();
     g_ThreadMallocTls->erase();
     g_ThreadMallocTls->erase();
-  }
-  if (pMalloc != nullptr) {
-    pMalloc->Release();
+    if (pMalloc != nullptr) {
+      pMalloc->Release();
+    }
   }
   }
 }
 }