Fixed bug 3720 - SDL_GL_GetAttribute doesn't check for initialized video driver

Simon Hug

SDL_GL_GetAttribute doesn't check if a video driver has been initialized and will access the SDL_VideoDevice pointer, which is NULL at that point.

I think all of the attributes require an initialized driver, so a simple NULL check should fix it. Patch is attached.
This commit is contained in:
Sam Lantinga
2017-07-31 12:57:15 -07:00
parent ee3f11d545
commit e10a98d2ad
2 changed files with 13 additions and 0 deletions

View File

@@ -3113,9 +3113,17 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
GLenum attachmentattrib = 0;
#endif
if (!value) {
return SDL_InvalidParamError("value");
}
/* Clear value in any case */
*value = 0;
if (!_this) {
return SDL_UninitializedVideo();
}
switch (attr) {
case SDL_GL_RED_SIZE:
#if SDL_VIDEO_OPENGL