Mesa (master): glsl: Add array access bounds checking to ir_validate
Ian Romanick
idr at kemper.freedesktop.org
Fri Mar 25 18:28:20 UTC 2011
Module: Mesa
Branch: master
Commit: bc83f6bd585bba6dee3fa2264d32ab59e9a9c99e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc83f6bd585bba6dee3fa2264d32ab59e9a9c99e
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Thu Mar 24 16:49:21 2011 -0700
glsl: Add array access bounds checking to ir_validate
---
src/glsl/ir_validate.cpp | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 0fc3baf..ec79d05 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;
}
More information about the mesa-commit
mailing list