glsl/linker: report linker errors for invalid explicit locations on inputs
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 24 Oct 2017 08:21:13 +0000 (10:21 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Thu, 26 Oct 2017 06:40:14 +0000 (08:40 +0200)
We were assuming that if an input has an invalid explicit location it would
fail to link because it would not find the corresponding output, however,
since we look for the matching output by indexing the explicit_locations
array with the input location, we still need to ensure that we don't index
out of bounds.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/compiler/glsl/link_varyings.cpp

index 69c92bf53b05022bddcbcf0ef4bb780798e3d97e..cb9091d86b451769d8c4ffe63b7fd4a1ca14c498 100644 (file)
@@ -556,6 +556,13 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
             unsigned slot_limit = idx + num_elements;
 
             while (idx < slot_limit) {
+               if (idx >= MAX_VARYING) {
+                  linker_error(prog,
+                               "Invalid location %u in %s shader\n", idx,
+                               _mesa_shader_stage_to_string(consumer->Stage));
+                  return;
+               }
+
                output = explicit_locations[idx][input->data.location_frac];
 
                if (output == NULL ||