[Mesa-dev] [PATCH 2/2] svga: silence array out of bounds warning

Brian Paul brianp at vmware.com
Mon Mar 4 17:20:58 UTC 2019


MinGW release build complains about a possible out-of-bounds
array access.  Test i < 4 to silence it.
---
 src/gallium/drivers/svga/svga_tgsi_insn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index c7804b2..1392a3c 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -2951,7 +2951,7 @@ svga_emit_immediate(struct svga_shader_emitter *emit,
    unsigned i;
 
    assert(1 <= imm->Immediate.NrTokens && imm->Immediate.NrTokens <= 5);
-   for (i = 0; i < imm->Immediate.NrTokens - 1; i++) {
+   for (i = 0; i < 4 && i < imm->Immediate.NrTokens - 1; i++) {
       float f = imm->u[i].Float;
       value[i] = util_is_inf_or_nan(f) ? 0.0f : f;
    }
-- 
1.8.5.6



More information about the mesa-dev mailing list