From bc83f6bd585bba6dee3fa2264d32ab59e9a9c99e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 24 Mar 2011 16:49:21 -0700 Subject: [PATCH] glsl: Add array access bounds checking to ir_validate --- src/glsl/ir_validate.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; } -- 2.30.2