Skip to content

Commit

Permalink
Don't release the backbuffer on error, we didn't acquire it.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Mar 9, 2020
1 parent 4e0fb11 commit 367a356
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/render/direct3d/SDL_render_d3d.c
Expand Up @@ -1462,20 +1462,17 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,

result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
if (FAILED(result)) {
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("GetDesc()", result);
}

result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
if (FAILED(result)) {
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("CreateOffscreenPlainSurface()", result);
}

result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
if (FAILED(result)) {
IDirect3DSurface9_Release(surface);
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("GetRenderTargetData()", result);
}

Expand All @@ -1487,7 +1484,6 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
if (FAILED(result)) {
IDirect3DSurface9_Release(surface);
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("LockRect()", result);
}

Expand Down

0 comments on commit 367a356

Please sign in to comment.