From 609a6474f0284bf75dc53d5915449d01408fc5f2 Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 24 May 2018 10:53:43 +0000 Subject: [PATCH] Prevent crash in CD3D9RenderTarget::generateSurfaces when a CD3D9Texture has no IDirect3DTexture9. Increase log-warning level from information to error when CD3D9Texture::generateRenderTarget fails to generate a IDirect3DTexture9. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5614 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CD3D9RenderTarget.cpp | 22 ++++++++++++---------- source/Irrlicht/CD3D9Texture.cpp | 8 ++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/source/Irrlicht/CD3D9RenderTarget.cpp b/source/Irrlicht/CD3D9RenderTarget.cpp index d90a92f1..6e42e658 100644 --- a/source/Irrlicht/CD3D9RenderTarget.cpp +++ b/source/Irrlicht/CD3D9RenderTarget.cpp @@ -236,22 +236,24 @@ namespace irr if (!Surface[i] && Texture[i]) { IDirect3DTexture9* currentTexture = static_cast(Texture[i])->getDX9Texture(); - - IDirect3DSurface9* currentSurface = 0; - currentTexture->GetSurfaceLevel(0, ¤tSurface); - - Surface[i] = currentSurface; + if ( currentTexture ) + { + IDirect3DSurface9* currentSurface = 0; + currentTexture->GetSurfaceLevel(0, ¤tSurface); + Surface[i] = currentSurface; + } } } if (!DepthStencilSurface && DepthStencil) { IDirect3DTexture9* currentTexture = static_cast(DepthStencil)->getDX9Texture(); - - IDirect3DSurface9* currentSurface = 0; - currentTexture->GetSurfaceLevel(0, ¤tSurface); - - DepthStencilSurface = currentSurface; + if ( currentTexture ) + { + IDirect3DSurface9* currentSurface = 0; + currentTexture->GetSurfaceLevel(0, ¤tSurface); + DepthStencilSurface = currentSurface; + } } } } diff --git a/source/Irrlicht/CD3D9Texture.cpp b/source/Irrlicht/CD3D9Texture.cpp index d494cfa1..82677be6 100644 --- a/source/Irrlicht/CD3D9Texture.cpp +++ b/source/Irrlicht/CD3D9Texture.cpp @@ -353,13 +353,13 @@ void CD3D9Texture::generateRenderTarget() if (FAILED(hr)) { if (D3DERR_INVALIDCALL == hr) - os::Printer::log("Could not create render target texture", "Invalid Call"); + os::Printer::log("Could not create render target texture", "Invalid Call", irr::ELL_ERROR); else if (D3DERR_OUTOFVIDEOMEMORY == hr) - os::Printer::log("Could not create render target texture", "Out of Video Memory"); + os::Printer::log("Could not create render target texture", "Out of Video Memory", irr::ELL_ERROR); else if (E_OUTOFMEMORY == hr) - os::Printer::log("Could not create render target texture", "Out of Memory"); + os::Printer::log("Could not create render target texture", "Out of Memory", irr::ELL_ERROR); else - os::Printer::log("Could not create render target texture"); + os::Printer::log("Could not create render target texture", irr::ELL_ERROR); } } }