glsl: Add array access bounds checking to ir_validate

This commit is contained in:
Ian Romanick
2011-03-24 16:49:21 -07:00
parent cf290344cc
commit bc83f6bd58

View File

@@ -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;
}