From 5226f8c7b0025031e8540adc93ecfe0b36b8f90f Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 25 Aug 2010 22:42:13 +0300 Subject: glsl: fix crash with variable indexing into array in a struct Signed-off-by: Ian Romanick --- src/glsl/ast_to_hir.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 64b142fa35d..2fec02668d8 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -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(); } } -- cgit v1.2.3