i915g: Fix initial array index
authorStéphane Marchesin <marcheu@chromium.org>
Fri, 6 Sep 2013 17:45:27 +0000 (10:45 -0700)
committerStéphane Marchesin <marcheu@chromium.org>
Fri, 6 Sep 2013 18:05:24 +0000 (11:05 -0700)
Fixes "Out-of-bounds read" defect reported by Coverity.

src/gallium/drivers/i915/i915_state_emit.c

index 9c16e590003a1ade795f20a5be6514c1624ec079..71ac326c4d88c1fc25961647c83531f7d69e7c24 100644 (file)
@@ -142,7 +142,7 @@ static uint target_fixup(struct pipe_surface *p, int component)
       { PIPE_FORMAT_A8_UNORM,       { 0, 0, 0, S5_WRITEDISABLE_RED | S5_WRITEDISABLE_GREEN | S5_WRITEDISABLE_BLUE | S5_WRITEDISABLE_ALPHA}},
       { 0,                          { S5_WRITEDISABLE_RED, S5_WRITEDISABLE_GREEN, S5_WRITEDISABLE_BLUE, S5_WRITEDISABLE_ALPHA}}
    };
-   int i = sizeof(fixup_mask) / sizeof(*fixup_mask);
+   int i = sizeof(fixup_mask) / sizeof(*fixup_mask) - 1;
 
    if (p)
       for(i = 0; fixup_mask[i].format != 0; i++)