Skip to content

Commit 3e55f23

Browse files
Fixed delay loading the DLL in non-Debug builds
1 parent c354bcb commit 3e55f23

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/DxcSupport/dxcmem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ void DxcCleanupThreadMalloc() throw() {
5858

5959
IMalloc *DxcGetThreadMallocNoRef() throw() {
6060
if (g_ThreadMallocTls == nullptr) {
61+
// Some genious didn't take into account that when CRT starts up,
62+
// a static std::ferr is initialized whichg calls `new locale`.
63+
// And if you're overriding the `new`&`delete` operators globally,
64+
// its nice to not have them depend on global state or deference nullptrs.
65+
if (!g_pDefaultMalloc)
66+
CoGetMalloc(1, &g_pDefaultMalloc);
6167
return g_pDefaultMalloc;
6268
}
6369

0 commit comments

Comments
 (0)