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 1236

Summary: CreateCGImageSourceFromRWops leaks
Product: SDL_image Reporter: Mike <michrublev>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: 1.2.10   
Hardware: x86_64   
OS: Mac OS X 10.6   
Attachments: Test program
valgrind logfile - on current (1.2.10) version
valgrind logfile for patched libSDL_image

Description Mike 2011-06-24 00:41:23 UTC
Created attachment 633 [details]
Test program

CGDataProviderRef must be cleaned after usage.

Here is a proposed patch:
{{{
diff -r b1c1ec3a8d49 IMG_ImageIO.c
--- a/IMG_ImageIO.c	Thu Apr 07 07:50:52 2011 -0700
+++ b/IMG_ImageIO.c	Fri Jun 24 13:45:18 2011 +0700
@@ -103,6 +103,7 @@
 	// Get the CGImageSourceRef.
 	// The dictionary can be NULL or contain hints to help ImageIO figure out the image type.
 	source_ref = CGImageSourceCreateWithDataProvider(data_provider, hints_and_options);
+	CGDataProviderRelease(data_provider);
 	return source_ref;
 }
 
}}}

Attached are test program and valgrind's logfiles
Comment 1 Mike 2011-06-24 00:44:42 UTC
Created attachment 634 [details]
valgrind logfile - on current (1.2.10) version
Comment 2 Mike 2011-06-24 00:45:23 UTC
Created attachment 635 [details]
valgrind logfile for patched libSDL_image
Comment 3 Sam Lantinga 2011-12-31 09:39:09 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL_image/rev/ec183abd5996