# HG changeset patch # User Sam Lantinga <slouken@libsdl.org> # Date 1159051897 0 # Node ID 6bb97f41ab4bf047e271d74b7069db1c5a9f9c15 # Parent 12ef90a416313c2e3bcf233456a3cce41ca4f314 Fixed bug #329 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. diff -r 12ef90a41631 -r 6bb97f41ab4b include/SDL_compat.h --- a/include/SDL_compat.h Fri Sep 22 21:52:20 2006 +0000 +++ b/include/SDL_compat.h Sat Sep 23 22:51:37 2006 +0000 @@ -147,7 +147,7 @@ surface); extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); -extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); +extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title, const char **icon); extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask); extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface); diff -r 12ef90a41631 -r 6bb97f41ab4b src/SDL_compat.c --- a/src/SDL_compat.c Fri Sep 22 21:52:20 2006 +0000 +++ b/src/SDL_compat.c Sat Sep 23 22:51:37 2006 +0000 @@ -692,14 +692,17 @@ { if (wm_title) { SDL_free(wm_title); + } + if (title) { + wm_title = SDL_strdup(title); } else { - wm_title = SDL_strdup(title); + wm_title = NULL; } SDL_SetWindowTitle(SDL_VideoWindow, wm_title); } void -SDL_WM_GetCaption(char **title, char **icon) +SDL_WM_GetCaption(const char **title, const char **icon) { if (title) { *title = wm_title;