glsl: Use signed array index in update_max_array_access()
authorAnuj Phogat <anuj.phogat@gmail.com>
Mon, 22 Sep 2014 22:10:28 +0000 (15:10 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Wed, 22 Oct 2014 23:13:37 +0000 (16:13 -0700)
Avoids a crash in case of negative array index is used in a
shader program.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/glsl/ast_array_index.cpp

index 49a8574..ff0c757 100644 (file)
@@ -49,12 +49,12 @@ ast_array_specifier::print(void) const
  * loc and state to report the error.
  */
 static void
-update_max_array_access(ir_rvalue *ir, unsigned idx, YYLTYPE *loc,
+update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE *loc,
                         struct _mesa_glsl_parse_state *state)
 {
    if (ir_dereference_variable *deref_var = ir->as_dereference_variable()) {
       ir_variable *var = deref_var->var;
-      if (idx > var->data.max_array_access) {
+      if (idx > (int)var->data.max_array_access) {
          var->data.max_array_access = idx;
 
          /* Check whether this access will, as a side effect, implicitly cause
@@ -94,7 +94,7 @@ update_max_array_access(ir_rvalue *ir, unsigned idx, YYLTYPE *loc,
 
             assert(max_ifc_array_access != NULL);
 
-            if (idx > max_ifc_array_access[field_index]) {
+            if (idx > (int)max_ifc_array_access[field_index]) {
                max_ifc_array_access[field_index] = idx;
 
                /* Check whether this access will, as a side effect, implicitly