diff options
author | Jan Vesely <[email protected]> | 2015-01-14 16:12:06 -0500 |
---|---|---|
committer | José Fonseca <[email protected]> | 2015-01-21 14:06:02 +0000 |
commit | 3c3e60e050ea0850fcfeb5c4c2aa4f954d54d665 (patch) | |
tree | 1567635ba061bc56edd011da23c14d890a858a73 | |
parent | 3cb10cce371cb62e0c4a988ab939bf640b75ebab (diff) |
mesa: Add assert to check number of vector elements
The below code crashes when vector_elements <= 0
Fixes Warray-bounds warnings
Signed-off-by: Jan Vesely <[email protected]>
Reviewed-by: Jose Fonseca <[email protected]>
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index ce3af312083..038f66b6d9e 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1449,6 +1449,7 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) ir->val->accept(this); src = this->result; assert(src.file != PROGRAM_UNDEFINED); + assert(ir->type->vector_elements > 0); for (i = 0; i < 4; i++) { if (i < ir->type->vector_elements) { diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 98ab2c149f5..2ed7a3bf9b8 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2051,6 +2051,7 @@ glsl_to_tgsi_visitor::visit(ir_swizzle *ir) ir->val->accept(this); src = this->result; assert(src.file != PROGRAM_UNDEFINED); + assert(ir->type->vector_elements > 0); for (i = 0; i < 4; i++) { if (i < ir->type->vector_elements) { |