diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index 0614bc38e8..32473a8a1e 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -4767,8 +4767,10 @@ void DXGraphicsStateGuardian8::set_render_target() { _pD3DDevice->GetDepthStencilSurface(&pStencil); _pD3DDevice->SetRenderTarget(pBack,pStencil); - pBack->Release(); - pStencil->Release(); + if (pBack) + pBack->Release(); + if (pStencil) + pStencil->Release(); } ////////////////////////////////////////////////////////////////////