diff options
author | Marek Olšák <[email protected]> | 2015-04-11 14:40:09 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-04-16 18:36:29 +0200 |
commit | e2066a4344e05ab66442e5de5a3caa19f7809323 (patch) | |
tree | 34bb6bdf31ad7b6d9f3cb493c6341eae5b02e2c2 /src/mesa/state_tracker/st_glsl_to_tgsi.cpp | |
parent | dcc74d47c40bf117f2dfaa359f9de7faef2c2200 (diff) |
glsl_to_tgsi: add assertions for detecting out-of-bounds immediates access
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_glsl_to_tgsi.cpp')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 5344ff9a211..a38f1b60c8e 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4349,6 +4349,7 @@ struct st_translate { struct ureg_src *constants; int num_constants; struct ureg_src *immediates; + int num_immediates; struct ureg_dst outputs[PIPE_MAX_SHADER_OUTPUTS]; struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS]; struct ureg_dst address[3]; @@ -4569,6 +4570,7 @@ src_register(struct st_translate *t, const st_src_reg *reg) t->constants[reg->index] : ureg_imm4f(t->ureg, 0, 0, 0, 0); case PROGRAM_IMMEDIATE: + assert(reg->index >= 0 && reg->index < t->num_immediates); return t->immediates[reg->index]; case PROGRAM_INPUT: @@ -4689,6 +4691,7 @@ translate_tex_offset(struct st_translate *t, switch (in_offset->file) { case PROGRAM_IMMEDIATE: + assert(in_offset->index >= 0 && in_offset->index < t->num_immediates); imm_src = t->immediates[in_offset->index]; offset.File = imm_src.File; @@ -5334,6 +5337,8 @@ st_translate_program( ret = PIPE_ERROR_OUT_OF_MEMORY; goto out; } + t->num_immediates = program->num_immediates; + i = 0; foreach_in_list(immediate_storage, imm, &program->immediates) { assert(i < program->num_immediates); @@ -5385,6 +5390,7 @@ out: free(t->constants); t->num_constants = 0; free(t->immediates); + t->num_immediates = 0; if (t->error) { debug_printf("%s: translate error flag set\n", __func__); |