Fixed bug #329
authorSam Lantinga <slouken@libsdl.org>
Sat, 23 Sep 2006 22:51:37 +0000
changeset 20376bb97f41ab4b
parent 2036 12ef90a41631
child 2038 eb5aedc79992
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.
include/SDL_compat.h
src/SDL_compat.c
     1.1 --- a/include/SDL_compat.h	Fri Sep 22 21:52:20 2006 +0000
     1.2 +++ b/include/SDL_compat.h	Sat Sep 23 22:51:37 2006 +0000
     1.3 @@ -147,7 +147,7 @@
     1.4                                                              surface);
     1.5  extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
     1.6                                                 const char *icon);
     1.7 -extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
     1.8 +extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title, const char **icon);
     1.9  extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
    1.10  extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
    1.11  extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
     2.1 --- a/src/SDL_compat.c	Fri Sep 22 21:52:20 2006 +0000
     2.2 +++ b/src/SDL_compat.c	Sat Sep 23 22:51:37 2006 +0000
     2.3 @@ -692,14 +692,17 @@
     2.4  {
     2.5      if (wm_title) {
     2.6          SDL_free(wm_title);
     2.7 +    }
     2.8 +    if (title) {
     2.9 +        wm_title = SDL_strdup(title);
    2.10      } else {
    2.11 -        wm_title = SDL_strdup(title);
    2.12 +        wm_title = NULL;
    2.13      }
    2.14      SDL_SetWindowTitle(SDL_VideoWindow, wm_title);
    2.15  }
    2.16  
    2.17  void
    2.18 -SDL_WM_GetCaption(char **title, char **icon)
    2.19 +SDL_WM_GetCaption(const char **title, const char **icon)
    2.20  {
    2.21      if (title) {
    2.22          *title = wm_title;