Skip to content
Permalink
Browse files

Don't release the backbuffer on error, we didn't acquire it.

  • Loading branch information
slouken committed Mar 9, 2020
1 parent 4e0fb11 commit 367a3561323871e9aad880c0405ca6a0d4188055
Showing with 0 additions and 4 deletions.
  1. +0 −4 src/render/direct3d/SDL_render_d3d.c
@@ -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);
}

@@ -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);
}

0 comments on commit 367a356

Please sign in to comment.