Check nativeWindow pointer before dereferencing (#3185)

Fix access violation in headless mode during bgfx::shutdown().
This pointer is usually set by the SwapChainPanel which doesn't exist
in headless mode.

Co-authored-by: Yanna Kang <yaka@microsoft.com>
This commit is contained in:
Yanna
2023-10-16 11:25:15 -07:00
committed by GitHub
parent 7c440b339f
commit d952e5cfb3

View File

@@ -142,9 +142,9 @@ namespace bgfx
template<typename T>
static bool trySetSwapChain(IInspectable* nativeWindow, Dxgi::SwapChainI* swapChain, HRESULT* hr)
{
ISwapChainPanelNative* swapChainPanelNative;
ISwapChainPanelNative* swapChainPanelNative = NULL;
if (FAILED(nativeWindow->QueryInterface(__uuidof(T), (void**)&swapChainPanelNative))
if (NULL != nativeWindow && FAILED(nativeWindow->QueryInterface(__uuidof(T), (void**)&swapChainPanelNative))
|| NULL == swapChainPanelNative)
{
return false;