Merge pull request #14176 from jherico/fix/fb19156

Add additional safety checks to gl::Uniform::load
This commit is contained in:
Sam Gateau 2018-10-22 14:12:36 -07:00 committed by GitHub
commit 40b77c338c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,14 +14,17 @@ using namespace gl;
void Uniform::load(GLuint glprogram, int index) {
this->index = index;
const GLint NAME_LENGTH = 256;
GLchar glname[NAME_LENGTH];
GLint length = 0;
glGetActiveUniform(glprogram, index, NAME_LENGTH, &length, &size, &type, glname);
// Length does NOT include the null terminator
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetActiveUniform.xhtml
name = std::string(glname, length);
binding = glGetUniformLocation(glprogram, glname);
if (index > 0) {
static const GLint NAME_LENGTH = 1024;
GLchar glname[NAME_LENGTH];
memset(glname, 0, NAME_LENGTH);
GLint length = 0;
glGetActiveUniform(glprogram, index, NAME_LENGTH, &length, &size, &type, glname);
// Length does NOT include the null terminator
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetActiveUniform.xhtml
name = std::string(glname, length);
binding = glGetUniformLocation(glprogram, name.c_str());
}
}
bool isTextureType(GLenum type) {