From 1ed5d5c0e3350e2c9ffe42f698c68f13b1232a3e Mon Sep 17 00:00:00 2001 From: "Asad M. Zaman" Date: Fri, 19 Mar 2004 17:30:17 +0000 Subject: [PATCH] fixed a crash bug with a null pointer --- panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 5 +++-- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index c5fbfe1faf..4ecad47386 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -4855,14 +4855,15 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *pPresParams, DXScreenData **pScrn) { get_engine()->reset_all_windows(true);// reset with new swapchains by creating - *pScrn = NULL; + if (pScrn) + *pScrn = NULL; if(pPresParams!=&_pScrn->PresParams) memcpy(&_pScrn->PresParams,pPresParams,sizeof(D3DPRESENT_PARAMETERS)); return hr; } // release the old swapchain and create a new one - if (_pScrn->pSwapChain) { + if (_pScrn && _pScrn->pSwapChain) { _pScrn->pSwapChain->Release(); wdxdisplay8_cat.debug() << "SwapChain " << _pScrn->pSwapChain << " is released\n"; _pScrn->pSwapChain = NULL; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index a13535969e..c9369564f6 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -4855,14 +4855,15 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *pPresParams, DXScreenData **pScrn) { get_engine()->reset_all_windows(true);// reset with new swapchains by creating - *pScrn = NULL; + if (pScrn) + *pScrn = NULL; if(pPresParams!=&_pScrn->PresParams) memcpy(&_pScrn->PresParams,pPresParams,sizeof(D3DPRESENT_PARAMETERS)); return hr; } // release the old swapchain and create a new one - if (_pScrn->pSwapChain) { + if (_pScrn && _pScrn->pSwapChain) { _pScrn->pSwapChain->Release(); wdxdisplay9_cat.debug() << "SwapChain " << _pScrn->pSwapChain << " is released\n"; _pScrn->pSwapChain = NULL;