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 423

Summary: Potential memory leak in SDL_RWFromFile function
Product: SDL Reporter: Patrice Mandin <patmandin>
Component: fileAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 1.2.11   
Hardware: All   
OS: All   

Description Patrice Mandin 2007-04-21 11:58:55 UTC
Hello,

At the end of the function we got:
--8<--8<--
	if ( fp == NULL ) {
		SDL_SetError("Couldn't open %s", file);
	} else {
		rwops = SDL_RWFromFP(fp, 1);
	}
#else
	SDL_SetError("SDL not compiled with stdio support");
#endif /* !HAVE_STDIO_H */

	return(rwops);
--8<--8<--

In the if() statement, only an error message is set, but the rwops structure is not freed, and set to NULL, before being returned to the calling application.
Comment 1 Patrice Mandin 2007-04-21 12:03:39 UTC
Oops, sorry, did not read the whole function. The #ifdef stuff confused me.