Просмотр исходного кода

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 <[email protected]>
Yanna 2 лет назад
Родитель
Сommit
d952e5cfb3
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      src/dxgi.cpp

+ 2 - 2
src/dxgi.cpp

@@ -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;