From 5537eba4865fae2f9677e6dbc259d6165b55c107 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 7 Jan 2012 22:52:41 -0500 Subject: [PATCH] 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 | 5 +++++ src/video/x11/SDL_x11framebuffer.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index 53ee5560a..cf28add64 100755 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -113,6 +113,11 @@ void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window) { 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; diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 7344e6276..9eb015e34 100755 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -193,7 +193,14 @@ void 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);