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 329

Summary: SDL_free() fails in function SDL_WM_SetCaption
Product: SDL Reporter: Ian Carvalho <ian>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.0   
Hardware: x86   
OS: Linux   
URL: http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL/src/SDL_compat.c?revision=2708&view=markup

Description Ian Carvalho 2006-09-17 15:20:01 UTC
When running the program luvcview the following error is reported:

*** glibc detected *** free(): invalid next size (fast): 0x08066830 ***

On tracing it turns out to fail from SDL_WM_SetCaption()

On going through the function it looks like the SDL_free() function is called every alternate time with an invalid pointer that has already been freed.

To fix: remove the else in the statement.

Even better validate "title" and only if valid execute the code in the function.

The following is what I think the new code should look like... Please verify.

--- start new code ---
void
SDL_WM_SetCaption(const char *title, const char *icon)
{
    if (title) {
	if (wm_title) {
            SDL_free(wm_title);
        }

        wm_title = SDL_strdup(title);

    	SDL_SetWindowTitle(SDL_VideoWindow, wm_title);
    }
}
--- end new code ---
Comment 1 Sam Lantinga 2006-09-23 18:50:58 UTC
This is fixed in subversion, thanks!