Skip to content

Commit

Permalink
Check nativeWindow pointer before dereferencing (#3185)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
yanna and Yanna Kang authored Oct 16, 2023
1 parent 7c440b3 commit d952e5c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d952e5c

Please sign in to comment.