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 3c85b41c88cb774f5bd51efe9c36a4fccb7712f3..109171ef57a528ad8a66fd11537b713045010f40 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);