glsl: Eliminate out-of-bounds triop_vector_insert
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Tue, 18 Aug 2020 07:41:31 +0000 (10:41 +0300)
committerMarge Bot <eric+marge@anholt.net>
Fri, 21 Aug 2020 15:00:51 +0000 (15:00 +0000)
commite802bff69ee74983215d0c2b7e213fca6d68a97d
tree34d091a05deb63fd9fd205c5afc6814708f57625
parent5922d57a184fcb27955d959e949e1ef68873bd19
glsl: Eliminate out-of-bounds triop_vector_insert

Section 5.11 (Out-of-Bounds Accesses) of the GLSL 4.60 spec says:

 "In the subsections described above for array, vector, matrix and
  structure accesses, any out-of-bounds access produced undefined
  behavior.... Out-of-bounds writes may be discarded or overwrite
  other variables of the active program."

Fixes crashes when dereferencing gl_ClipDistance and gl_TessLevel*, e.g:

  int index = -1;
  gl_ClipDistance[index] = -1;

When LowerCombinedClipCullDistance is true.

CC: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marcin Ĺšlusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6363>
src/compiler/glsl/lower_vector_insert.cpp