Fixed bug 1333 - segfault if opengl window could not get created
authorSam Lantinga <slouken@libsdl.org>
Sat, 07 Jan 2012 22:52:41 -0500
changeset 6180 744ae9bdf5da
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
--- a/src/video/windows/SDL_windowsframebuffer.c	Sat Jan 07 22:34:51 2012 -0500
+++ b/src/video/windows/SDL_windowsframebuffer.c	Sat Jan 07 22:52:41 2012 -0500
@@ -113,6 +113,11 @@
 {
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
 
+    if (!data) {
+        /* The window wasn't fully initialized */
+        return;
+    }
+
     if (data->mdc) {
         DeleteDC(data->mdc);
         data->mdc = NULL;
--- a/src/video/x11/SDL_x11framebuffer.c	Sat Jan 07 22:34:51 2012 -0500
+++ b/src/video/x11/SDL_x11framebuffer.c	Sat Jan 07 22:52:41 2012 -0500
@@ -193,7 +193,14 @@
 X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
 {
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
-    Display *display = data->videodata->display;
+    Display *display;
+
+    if (!data) {
+        /* The window wasn't fully initialized */
+        return;
+    }
+
+    display = data->videodata->display;
 
     if (data->ximage) {
         XDestroyImage(data->ximage);