Don't release the backbuffer on error, we didn't acquire it.
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 932c183..8385933 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/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);
}