summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/api_validate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/api_validate.c')
-rw-r--r--src/mesa/main/api_validate.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 184bf143edf..44d164ad355 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -724,12 +724,32 @@ GLboolean
_mesa_validate_MultiDrawElements(struct gl_context *ctx,
GLenum mode, const GLsizei *count,
GLenum type, const GLvoid * const *indices,
- GLuint primcount)
+ GLsizei primcount)
{
- unsigned i;
+ GLsizei i;
FLUSH_CURRENT(ctx, 0);
+ /*
+ * Section 2.3.1 (Errors) of the OpenGL 4.5 (Core Profile) spec says:
+ *
+ * "If a negative number is provided where an argument of type sizei or
+ * sizeiptr is specified, an INVALID_VALUE error is generated."
+ *
+ * and in the same section:
+ *
+ * "In other cases, there are no side effects unless otherwise noted;
+ * the command which generates the error is ignored so that it has no
+ * effect on GL state or framebuffer contents."
+ *
+ * Hence, check both primcount and all the count[i].
+ */
+ if (primcount < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glMultiDrawElements(primcount=%d)", primcount);
+ return GL_FALSE;
+ }
+
for (i = 0; i < primcount; i++) {
if (count[i] < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,