r300: Fix out-of-bounds access in ntr_emit_store_output()
authorCong Liu <liucong2@kylinos.cn>
Wed, 27 Sep 2023 07:30:14 +0000 (15:30 +0800)
committerMarge Bot <emma+marge@anholt.net>
Thu, 28 Sep 2023 09:51:38 +0000 (09:51 +0000)
This patch resolves the problem by modifying the for loop condition
to ensure that it stays within the bounds of the array (i.e., i < 4)

Signed-off-by: Cong Liu <liucong2@kylinos.cn>
Reviewed-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25419>

src/gallium/drivers/r300/compiler/nir_to_rc.c

index f71ecef..17f1594 100644 (file)
@@ -1528,7 +1528,7 @@ ntr_emit_store_output(struct ntr_compile *c, nir_intrinsic_instr *instr)
    }
 
    uint8_t swizzle[4] = { 0, 0, 0, 0 };
-   for (int i = frac; i <= 4; i++) {
+   for (int i = frac; i < 4; i++) {
       if (out.WriteMask & (1 << i))
          swizzle[i] = i - frac;
    }