mirror of https://github.com/axmolengine/axmol.git
fix buffer overflow in CCGLProgram.cpp in memcmp call (Address Sanitizer spots it easily)
- previously the flow went memcmp, if that != 0, do a bounds check, etc - now do a bounds check, if destSize >= srcSize, do memcmp, etc
This commit is contained in:
parent
b0d0a7a064
commit
15c6788783
|
@ -640,17 +640,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);
|
||||
|
|
Loading…
Reference in New Issue