Merge pull request #16101 from mtak-/glprogram_buffer_overflow_fix

fix buffer over-read in CCGLProgram.cpp in memcmp call (Address Sanitizer...
This commit is contained in:
Ricardo Quesada 2016-07-14 17:12:17 -07:00 committed by GitHub
commit 9166c28e75
1 changed files with 6 additions and 6 deletions

View File

@ -651,17 +651,17 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign
}
else
{
if (memcmp(element->second.first, data, bytes) == 0)
if (element->second.second < bytes)
{
updated = false;
GLvoid* value = realloc(element->second.first, bytes);
memcpy(value, data, bytes);
_hashForUniforms[location] = std::make_pair(value, bytes);
}
else
{
if (element->second.second < bytes)
if (memcmp(element->second.first, data, bytes) == 0)
{
GLvoid* value = realloc(element->second.first, bytes);
memcpy(value, data, bytes );
_hashForUniforms[location] = std::make_pair(value, bytes);
updated = false;
}
else
memcpy(element->second.first, data, bytes);