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.
--- 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);