glsl/linker: link error on too many subroutine functions.
authorDave Airlie <airlied@redhat.com>
Tue, 17 May 2016 04:52:38 +0000 (14:52 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 23 May 2016 06:19:56 +0000 (16:19 +1000)
This fixes:
GL45-CTS.explicit_uniform_location.subroutine-index-negative-link-max-num-of-indices

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/compiler/glsl/linker.cpp

index ef8db563bb288dca14f91934c76715e98c8715ad..4c567fca549485b962b78265fd46b39e43f37f61 100644 (file)
@@ -4229,6 +4229,10 @@ link_assign_subroutine_types(struct gl_shader_program *prog)
          if (!fn->num_subroutine_types)
             continue;
 
+         if (sh->NumSubroutineFunctions + 1 > MAX_SUBROUTINES) {
+            linker_error(prog, "Too many subroutine functions declared.\n");
+            return;
+         }
          sh->SubroutineFunctions = reralloc(sh, sh->SubroutineFunctions,
                                             struct gl_subroutine_function,
                                             sh->NumSubroutineFunctions + 1);