draw: check bitshift against PIPE_MAX_SHADER_OUTPUS
authorBrian Paul <brianp@vmware.com>
Mon, 20 Sep 2010 21:34:02 +0000 (15:34 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 20 Sep 2010 21:34:02 +0000 (15:34 -0600)
src/gallium/auxiliary/draw/draw_pipe_wide_point.c

index 40843c58c2090ea7229f06faa24a18c960da77d7..3646c6a7145d6e3d39959b4910a775b0b4365b3a 100644 (file)
@@ -237,7 +237,11 @@ widepoint_first_point(struct draw_stage *stage,
       for (i = 0; i < fs->info.num_inputs; i++) {
          if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
             const int generic_index = fs->info.input_semantic_index[i];
-            if (rast->sprite_coord_enable & (1 << generic_index)) {
+            /* Note that sprite_coord enable is a bitfield of
+             * PIPE_MAX_SHADER_OUTPUTS bits.
+             */
+            if (generic_index < PIPE_MAX_SHADER_OUTPUTS &&
+                (rast->sprite_coord_enable & (1 << generic_index))) {
                /* OK, this generic attribute needs to be replaced with a
                 * texcoord (see above).
                 */