nir: coverity unitialized pointer read
authorRob Clark <robclark@freedesktop.org>
Wed, 18 May 2016 14:38:40 +0000 (10:38 -0400)
committerRob Clark <robclark@freedesktop.org>
Fri, 20 May 2016 15:13:50 +0000 (11:13 -0400)
Not sure how coverity arrives at the conclusion that we can read comp[j]
unitialized (around line 204), other than not being aware that ncomp is
greater than 1 so it won't underflow in the 'if (tex->is_array)' case.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/compiler/nir/nir_lower_tex.c

index a080475409863cfbacd5bd436c770fc16e2a9566..2086263e3fc91a1e9b99d73c0e99fad979885f3c 100644 (file)
@@ -177,6 +177,8 @@ saturate_src(nir_builder *b, nir_tex_instr *tex, unsigned sat_mask)
       /* split src into components: */
       nir_ssa_def *comp[4];
 
+      assume(tex->coord_components >= 1);
+
       for (unsigned j = 0; j < tex->coord_components; j++)
          comp[j] = nir_channel(b, src, j);