summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2011-03-24 16:49:21 -0700
committerIan Romanick <ian.d.romanick@intel.com>2011-03-25 11:28:07 -0700
commitbc83f6bd585bba6dee3fa2264d32ab59e9a9c99e (patch)
treedf6a375a3fd6564179fef949b4473b33b424de4e
parentcf290344cc6c61b81452a28d739021a7f11b11bc (diff)
glsl: Add array access bounds checking to ir_validate
-rw-r--r--src/glsl/ir_validate.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 0fc3baf8690..ec79d05cae9 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -473,6 +473,21 @@ ir_validate::visit(ir_variable *ir)
assert(ralloc_parent(ir->name) == ir);
hash_table_insert(ht, ir, ir);
+
+
+ /* If a variable is an array, verify that the maximum array index is in
+ * bounds. There was once an error in AST-to-HIR conversion that set this
+ * to be out of bounds.
+ */
+ if (ir->type->array_size() > 0) {
+ if (ir->max_array_access >= ir->type->length) {
+ printf("ir_variable has maximum access out of bounds (%d vs %d)\n",
+ ir->max_array_access, ir->type->length - 1);
+ ir->print();
+ abort();
+ }
+ }
+
return visit_continue;
}