Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug 1722 - An attempt to release NULL Direct3d surface

Evgeny

static void
D3D_DestroyRenderer(SDL_Renderer * renderer)

has a critical problem. It may try to release IDirect3DSurface9 surface pointed
by NULL pointer. That leads to really wierd consequences on my system.

It happens when the previous call to IDirect3D9_CreateDevice() fails leaving
D3D_RenderData::defaultRenderTarget uninitialized.
  • Loading branch information
slouken committed Feb 18, 2013
1 parent 936c82b commit ac2ff24b2b67d3d4733b8b0c98376897ebff1338
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/render/direct3d/SDL_render_d3d.c
@@ -362,7 +362,10 @@ D3D_Reset(SDL_Renderer * renderer)
HRESULT result;

/* Release the default render target before reset */
IDirect3DSurface9_Release(data->defaultRenderTarget);
if (data->defaultRenderTarget) {
IDirect3DSurface9_Release(data->defaultRenderTarget);
data->defaultRenderTarget = NULL;
}

result = IDirect3DDevice9_Reset(data->device, &data->pparams);
if (FAILED(result)) {
@@ -1486,7 +1489,10 @@ D3D_DestroyRenderer(SDL_Renderer * renderer)

if (data) {
// Release the render target
IDirect3DSurface9_Release(data->defaultRenderTarget);
if (data->defaultRenderTarget) {
IDirect3DSurface9_Release(data->defaultRenderTarget);
data->defaultRenderTarget = NULL;
}
if (data->currentRenderTarget != NULL) {
IDirect3DSurface9_Release(data->currentRenderTarget);
data->currentRenderTarget = NULL;

0 comments on commit ac2ff24

Please sign in to comment.