llvmpipe: check bitshift against PIPE_MAX_SHADER_OUTPUTS
authorBrian Paul <brianp@vmware.com>
Mon, 20 Sep 2010 21:33:49 +0000 (15:33 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 20 Sep 2010 21:33:49 +0000 (15:33 -0600)
src/gallium/drivers/llvmpipe/lp_setup_point.c

index bb6b88069bfdca259fdc4e579b03f95d85335ccb..774a3c80dad7ae949c5b23f656d893f3e598505c 100644 (file)
@@ -188,8 +188,11 @@ setup_point_coefficients( struct lp_setup_context *setup,
           */
          if (shader->info.input_semantic_name[slot] == TGSI_SEMANTIC_GENERIC) {
             const int index = shader->info.input_semantic_index[slot];
-            
-            if (setup->sprite_coord_enable & (1 << index)) {
+            /* Note that sprite_coord enable is a bitfield of
+             * PIPE_MAX_SHADER_OUTPUTS bits.
+             */
+            if (index < PIPE_MAX_SHADER_OUTPUTS &&
+                (setup->sprite_coord_enable & (1 << index))) {
                for (i = 0; i < NUM_CHANNELS; i++)
                   if (usage_mask & (1 << i))
                      perspective_coef(setup, point, info, slot+1, vert_attr, i,