glsl: add missing check for samplers in set_opaque_binding()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 11 May 2017 10:31:26 +0000 (12:31 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 11 May 2017 19:08:28 +0000 (21:08 +0200)
Like images, this prevents out-of-bound access when the explicit
binding layout qualifier is used with an array which contains
too much samplers.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/link_uniform_initializers.cpp

index 8911c3de62aeab8543a4d7d351e176b2736de239..79a6c75aaa808b001620d0093ff9f2762f3bec3d 100644 (file)
@@ -135,6 +135,8 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
             if (storage->type->is_sampler() && storage->opaque[sh].active) {
                for (unsigned i = 0; i < elements; i++) {
                   const unsigned index = storage->opaque[sh].index + i;
+                  if (index >= ARRAY_SIZE(shader->Program->SamplerUnits))
+                     break;
                   shader->Program->SamplerUnits[index] =
                      storage->storage[i].i;
                }