Fixed bug 1333 - segfault if opengl window could not get created
authorSam Lantinga
Sat, 07 Jan 2012 22:52:41 -0500
changeset 6180744ae9bdf5da
parent 6179 a83eb92704f3
child 6181 e29f01fa2750
Fixed bug 1333 - segfault if opengl window could not get created

When the window couldn't be created, the normal window destruction process happens, which among other things, destroys the framebuffer, if any.
src/video/windows/SDL_windowsframebuffer.c
src/video/x11/SDL_x11framebuffer.c
     1.1 --- a/src/video/windows/SDL_windowsframebuffer.c	Sat Jan 07 22:34:51 2012 -0500
     1.2 +++ b/src/video/windows/SDL_windowsframebuffer.c	Sat Jan 07 22:52:41 2012 -0500
     1.3 @@ -113,6 +113,11 @@
     1.4  {
     1.5      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     1.6  
     1.7 +    if (!data) {
     1.8 +        /* The window wasn't fully initialized */
     1.9 +        return;
    1.10 +    }
    1.11 +
    1.12      if (data->mdc) {
    1.13          DeleteDC(data->mdc);
    1.14          data->mdc = NULL;
     2.1 --- a/src/video/x11/SDL_x11framebuffer.c	Sat Jan 07 22:34:51 2012 -0500
     2.2 +++ b/src/video/x11/SDL_x11framebuffer.c	Sat Jan 07 22:52:41 2012 -0500
     2.3 @@ -193,7 +193,14 @@
     2.4  X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
     2.5  {
     2.6      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     2.7 -    Display *display = data->videodata->display;
     2.8 +    Display *display;
     2.9 +
    2.10 +    if (!data) {
    2.11 +        /* The window wasn't fully initialized */
    2.12 +        return;
    2.13 +    }
    2.14 +
    2.15 +    display = data->videodata->display;
    2.16  
    2.17      if (data->ximage) {
    2.18          XDestroyImage(data->ximage);