Commit ff5d3dc6 by Corentin Wallez

gl::GetString check for a valid context

glGetString() without a current context could cause a null dereference for some enums. Always return nullptr when no context is bound. BUG=angleproject:1106 Change-Id: Ic36f1adff8b2e3cd54a7b33b2e12899781feba82 Reviewed-on: https://chromium-review.googlesource.com/295142Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 80b2411a
......@@ -2482,44 +2482,50 @@ const GLubyte *GL_APIENTRY GetString(GLenum name)
Context *context = GetValidGlobalContext();
switch (name)
if (context)
{
case GL_VENDOR:
return (GLubyte*)"Google Inc.";
switch (name)
{
case GL_VENDOR:
return reinterpret_cast<const GLubyte *>("Google Inc.");
case GL_RENDERER:
return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
case GL_RENDERER:
return reinterpret_cast<const GLubyte *>(context->getRendererString().c_str());
case GL_VERSION:
if (context->getClientVersion() == 2)
{
return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
}
else
{
return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
}
case GL_VERSION:
if (context->getClientVersion() == 2)
{
return reinterpret_cast<const GLubyte *>(
"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")");
}
else
{
return reinterpret_cast<const GLubyte *>(
"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")");
}
case GL_SHADING_LANGUAGE_VERSION:
if (context->getClientVersion() == 2)
{
return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
}
else
{
return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
}
case GL_SHADING_LANGUAGE_VERSION:
if (context->getClientVersion() == 2)
{
return reinterpret_cast<const GLubyte *>(
"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")");
}
else
{
return reinterpret_cast<const GLubyte *>(
"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")");
}
case GL_EXTENSIONS:
return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
case GL_EXTENSIONS:
return reinterpret_cast<const GLubyte *>(context->getExtensionString().c_str());
default:
if (context)
{
default:
context->recordError(Error(GL_INVALID_ENUM));
return nullptr;
}
return NULL;
}
return nullptr;
}
void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment