Commit 2a353a75 by Geoff Lang

Split the overflow check into explicit multiplication and addition overflow checks.

TRAC #23671 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Geoff Lang
parent 662c3afa
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 2 #define MINOR_VERSION 2
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 2433 #define BUILD_REVISION 2434
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -140,9 +140,9 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer ...@@ -140,9 +140,9 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer
unsigned int typeSize = gl::ComputeTypeSize(type); unsigned int typeSize = gl::ComputeTypeSize(type);
// check for integer overflows and underflows // check for integer overflows
if (static_cast<unsigned int>(offset) > (std::numeric_limits<unsigned int>::max() / typeSize) || if (static_cast<unsigned int>(count) > (std::numeric_limits<unsigned int>::max() / typeSize) ||
static_cast<unsigned int>(count) > ((std::numeric_limits<unsigned int>::max() / typeSize) - offset)) typeSize * static_cast<unsigned int>(count) + offset < offset)
{ {
return GL_OUT_OF_MEMORY; return GL_OUT_OF_MEMORY;
} }
......
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