arb_shader_subroutine: check active subroutine limit
authorDave Airlie <airlied@redhat.com>
Tue, 28 Jul 2015 06:11:06 +0000 (07:11 +0100)
committerDave Airlie <airlied@redhat.com>
Mon, 23 May 2016 06:18:25 +0000 (16:18 +1000)
_mesa_GetActiveSubroutineUniformiv needs to check
against the number of types here.

Noticed while playing with ogl conform.

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/main/shaderapi.c

index 3c85b41..109171e 100644 (file)
@@ -2369,6 +2369,11 @@ _mesa_GetActiveSubroutineUniformiv(GLuint program, GLenum shadertype,
       return;
    }
 
+   if (index >= sh->NumSubroutineUniformTypes) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s: invalid index greater than GL_ACTIVE_SUBROUTINE_UNIFORMS", api_name);
+      return;
+   }
+
    switch (pname) {
    case GL_NUM_COMPATIBLE_SUBROUTINES: {
       res = _mesa_program_resource_find_index(shProg, resource_type, index);