Mesa (master): glsl: In update_max_array_access, fix interface instance check.

Paul Berry stereotype441 at kemper.freedesktop.org
Thu Oct 17 19:04:49 UTC 2013


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Tue Oct 15 09:43:22 2013 -0700

glsl: In update_max_array_access, fix interface instance check.

In commit f878d20 (glsl: Update ir_variable::max_ifc_array_access
properly), I accidentally used the wrong kind of check to determine
whether the variable being accessed was an interface instance (I used
var->get_interface_type() != NULL when I should have used
var->is_interface_instance()).  As a result, if an unnamed interface
block contained a struct which contained an array,
update_max_array_access() would mistakenly interpret the struct as a
named interface block and try to dereference a null
var->max_ifc_array_access.

This patch corrects the check, fixing the null dereference.

Fixes piglit test interface-block-struct-nesting.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70368

Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/glsl/ast_array_index.cpp |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
index da96cc1..b457ec8 100644
--- a/src/glsl/ast_array_index.cpp
+++ b/src/glsl/ast_array_index.cpp
@@ -69,9 +69,9 @@ update_max_array_access(ir_rvalue *ir, unsigned idx, YYLTYPE *loc,
       }
 
       if (deref_var != NULL) {
-         const glsl_type *interface_type =
-            deref_var->var->get_interface_type();
-         if (interface_type != NULL) {
+         if (deref_var->var->is_interface_instance()) {
+            const glsl_type *interface_type =
+               deref_var->var->get_interface_type();
             unsigned field_index =
                deref_record->record->type->field_index(deref_record->field);
             assert(field_index < interface_type->length);




More information about the mesa-commit mailing list