We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5018

Summary: D3D_RenderReadPixels - possible memory leak
Product: SDL Reporter: Konrad <iryont>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: All   
Attachments: Fix

Description Konrad 2020-03-08 10:23:23 UTC
Created attachment 4243 [details]
Fix

It appears that backbuffer is not released at the end of the function like in any previous error return within if.

Patch included.
Comment 1 Sam Lantinga 2020-03-08 22:49:41 UTC
Actually, it looks like releasing the backbuffer isn't correct here, and should be removed from the error handling. We're just copying the pointer at the top of the function, not increasing the reference count to it...
Comment 2 Konrad 2020-03-08 22:54:52 UTC
Ahh, you are perfectly right.

I was using GetRenderTarget myself in a different application which does increase ref count, but I didn't notice that SDL2 does not get it, but just copy the already acquired pointer.
Comment 3 Sam Lantinga 2020-03-09 01:56:57 UTC
I fixed it so it doesn't release the backbuffer on error.

Thanks!