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 - SDL_free() fails in function SDL_WM_SetCaption
Summary: SDL_free() fails in function SDL_WM_SetCaption
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.0
Hardware: x86 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL: http://www.libsdl.org/cgi/viewvc.cgi/...
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-17 15:20 UTC by Ian Carvalho
Modified: 2006-09-23 18:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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!