Mesa (master): glsl: fix crash with variable indexing into array in a struct

Ian Romanick idr at kemper.freedesktop.org
Wed Aug 25 23:29:14 UTC 2010


Module: Mesa
Branch: master
Commit: 5226f8c7b0025031e8540adc93ecfe0b36b8f90f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5226f8c7b0025031e8540adc93ecfe0b36b8f90f

Author: Aras Pranckevicius <aras at unity3d.com>
Date:   Wed Aug 25 22:42:13 2010 +0300

glsl: fix crash with variable indexing into array in a struct

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/glsl/ast_to_hir.cpp |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 64b142f..2fec026 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();
 	 }
       }
 




More information about the mesa-commit mailing list