Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1313 - Segfault on SDL_CreateWindow when gl lib cannot be l…
Browse files Browse the repository at this point in the history
…oaded

Don't crash if the gl_data isn't valid, just return NULL.
  • Loading branch information
slouken committed Jan 8, 2012
1 parent 5537eba commit ee707b5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/video/x11/SDL_x11opengl.c
Expand Up @@ -187,8 +187,10 @@ X11_GL_UnloadLibrary(_THIS)
#endif

/* Free OpenGL memory */
SDL_free(_this->gl_data);
_this->gl_data = NULL;
if (_this->gl_data) {
SDL_free(_this->gl_data);
_this->gl_data = NULL;
}
}

static SDL_bool
Expand Down Expand Up @@ -396,6 +398,11 @@ X11_GL_GetVisual(_THIS, Display * display, int screen)
const int i = X11_GL_GetAttributes(_this,display,screen,attribs,max_attrs);
SDL_assert(i <= max_attrs);

if (!_this->gl_data) {
/* The OpenGL library wasn't loaded, SDL_GetError() should have info */
return NULL;
}

vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs);
if (!vinfo) {
SDL_SetError("Couldn't find matching GLX visual");
Expand Down

0 comments on commit ee707b5

Please sign in to comment.