glsl: Fix overflow of ImageAccess[] array.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 14 Feb 2016 00:58:35 +0000 (16:58 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 14 Feb 2016 05:12:18 +0000 (21:12 -0800)
commit565aa69970ccb0e92c9d5773c43d9b49e7bdb8e4
tree0075951ad7b4d96a4d5010ea6712ff82a9810ce5
parent6411444c364f67a4a597f8e025c9025440aa054a
glsl: Fix overflow of ImageAccess[] array.

The ImageAccess array is statically sized to MAX_IMAGE_UNIFORMS:

   GLenum ImageAccess[MAX_IMAGE_UNIFORMS];

There was no bounds checking ensuring we don't overflow.  Passing in a
shader with too many uniforms would cause writes to extend into other
fields, such as sh->NumImages.

Later linker checks already handle reporting an error when there are too
many images, so just avoid corrupting structures here.

This rearranges the logic a bit to look more like the sampler case.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Tested-by: Jordan Justen <jordan.l.justen@intel.com>
src/compiler/glsl/link_uniforms.cpp