glsl: fix crash with variable indexing into array in a struct
authorAras Pranckevicius <aras@unity3d.com>
Wed, 25 Aug 2010 19:42:13 +0000 (22:42 +0300)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Aug 2010 23:22:44 +0000 (16:22 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/ast_to_hir.cpp

index 64b142fa35d777244879787bd0f30c26ec7ea626..2fec02668d8f91e5aa2d07a296fa99386c356127 100644 (file)
@@ -1259,8 +1259,14 @@ ast_expression::hir(exec_list *instructions,
         _mesa_glsl_error(&loc, state, "unsized array index must be constant");
       } else {
         if (array->type->is_array()) {
+           /* whole_variable_referenced can return NULL if the array is a
+            * member of a structure.  In this case it is safe to not update
+            * the max_array_access field because it is never used for fields
+            * of structures.
+            */
            ir_variable *v = array->whole_variable_referenced();
-           v->max_array_access = array->type->array_size();
+           if (v != NULL)
+              v->max_array_access = array->type->array_size();
         }
       }