Possible crash in Direct3D9TextureTarget

Issue #445 resolved
Former user created an issue

Automatic migration. Original reporter: "MarkR"

void Direct3D9TextureTarget::enableRenderTexture():

The return value of "d_device->GetRenderTarget(0, &oldSurface)" isn't checked and the "oldSurface" member isn't initialized accordingly, so a call to Direct3D9TextureTarget::disableRenderTexture() may lead to a crash.

Reproducibility: N/A

Steps to reproduce: Not really known. This happens with ts3overlay (http://ts3overlay.r-dev.de) when injecting into the game "Runes of Magic" and minimizing / restoring a full-screen application.

Additional information: void Direct3D9TextureTarget::enableRenderTexture() { - LPDIRECT3DSURFACE9 oldSurface; + LPDIRECT3DSURFACE9 oldSurface(0); d_device->GetRenderTarget(0, &oldSurface);

if (oldSurface && oldSurface != d_surface) { d_prevColourSurface = oldSurface; d_device->SetRenderTarget(0, d_surface); } else if (oldSurface) oldSurface->Release(); }

---------------------------------------------------------------------------- void Direct3D9TextureTarget::disableRenderTexture() { d_device->SetRenderTarget(0, d_prevColourSurface); - d_prevColourSurface->Release(); + if (d_prevColourSurface) + d_prevColourSurface->Release(); }

OS: Windows, OS build: any, Platform:

Comments (1)

  1. Paul Turner

    changeset: 3138:9b8221761c80 user: Paul Turner <paul@cegui.org.uk> date: Sat Feb 25 19:40:11 2012 +0000 summary: Fix: Direct3D9 implementaion of TextureTarget was not correctly handling possible failure case, and elsewhere was not testing pointer before dereferencing it.

  2. Log in to comment