From: Ian Romanick Date: Thu, 24 Mar 2011 23:49:21 +0000 (-0700) Subject: glsl: Add array access bounds checking to ir_validate X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bc83f6bd585bba6dee3fa2264d32ab59e9a9c99e;p=mesa.git glsl: Add array access bounds checking to ir_validate --- 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; }