Validate vertex element sizes.
Change-Id: I03fabec6a92ef058aa2968418755aca079598cfe
Reviewed-on: https://swiftshader-review.googlesource.com/3781
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.cpp b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
index bfde11c..2d3f6fa 100644
--- a/src/OpenGL/libGLES_CM/libGLES_CM.cpp
+++ b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
@@ -680,6 +680,11 @@
{
TRACE("(GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid *pointer = %p)", size, type, stride, pointer);
+ if(size != 4)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
VertexAttribPointer(sw::Color0, size, type, true, stride, pointer);
}
@@ -2857,6 +2862,11 @@
{
TRACE("(GLfloat size = %f)", size);
+ if(size <= 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
es1::Context *context = es1::getContext();
if(context)
@@ -3185,6 +3195,11 @@
{
TRACE("(GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid *pointer = %p)", size, type, stride, pointer);
+ if(size < 2 || size > 4)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
es1::Context *context = es1::getContext();
if(context)
@@ -4108,6 +4123,11 @@
{
TRACE("(GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid *pointer = %p)", size, type, stride, pointer);
+ if(size < 2 || size > 4)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
VertexAttribPointer(sw::Position, size, type, false, stride, pointer);
}