Skip to content

Commit 4ee59f6

Browse files
authored
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.
1 parent 1450ea8 commit 4ee59f6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/DxcSupport/dxcmem.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ IMalloc *DxcGetThreadMallocNoRef() throw() {
5858
}
5959

6060
void DxcClearThreadMalloc() throw() {
61-
DXASSERT(g_ThreadMallocTls != nullptr, "else prior to DxcInitThreadMalloc or after DxcCleanupThreadMalloc");
6261
IMalloc *pMalloc = DxcGetThreadMallocNoRef();
63-
g_ThreadMallocTls->erase();
64-
pMalloc->Release();
62+
if (g_ThreadMallocTls != nullptr) {
63+
g_ThreadMallocTls->erase();
64+
}
65+
if (pMalloc != nullptr) {
66+
pMalloc->Release();
67+
}
6568
}
6669

6770
void DxcSetThreadMallocToDefault() throw() {

0 commit comments

Comments
 (0)