Commit 0b78533f by Geoff Lang Committed by Geoff Lang

Fix additional overflow and underflow issues with line loops.

Issue #444 Signed-off-by: Shannon Woods Signed-off-by: Chris Evans Author: Geoff Lang
parent 74fe3199
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 2254
#define BUILD_REVISION 2255
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -3253,11 +3253,14 @@ void Context::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, in
if (supports32bitIndices())
{
if (static_cast<unsigned int>(count + 1) > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int)))
// Verified by the glDraw* functions
ASSERT(count >= 0);
if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int)))
{
return error(GL_OUT_OF_MEMORY);
}
const unsigned int spaceNeeded = (count + 1) * sizeof(unsigned int);
const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned int);
if (!mLineLoopIB)
{
......@@ -3314,11 +3317,14 @@ void Context::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, in
}
else
{
if (static_cast<unsigned short>(count + 1) > (std::numeric_limits<unsigned short>::max() / sizeof(unsigned short)))
// Verified by the glDraw* functions
ASSERT(count >= 0);
if (static_cast<unsigned short>(count) + 1 > (std::numeric_limits<unsigned short>::max() / sizeof(unsigned short)))
{
return error(GL_OUT_OF_MEMORY);
}
const unsigned int spaceNeeded = (count + 1) * sizeof(unsigned short);
const unsigned int spaceNeeded = (static_cast<unsigned short>(count) + 1) * sizeof(unsigned short);
if (!mLineLoopIB)
{
......
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