From: Li Qiang Date: Mon, 23 Jan 2017 07:44:03 +0000 (-0500) Subject: gallium/tgsi: fix oob access in parse instruction X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83fb63d31de51cd49a947f68393672e97b307f37;p=mesa.git gallium/tgsi: fix oob access in parse instruction When parsing texture instruction, it doesn't stop if the 'cur' is ',', the loop variable 'i' will also be increased and be used to index the 'inst.TexOffsets' array. This can lead an oob access issue. This patch avoid this. Reviewed-by: Dave Airlie Signed-off-by: Li Qiang --- diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 308e6b52627..4ed905036f1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -1163,7 +1163,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;