llvmpipe: do some null pointer checking
authorBrian Paul <brianp@vmware.com>
Tue, 4 May 2010 19:23:41 +0000 (13:23 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 4 May 2010 23:17:04 +0000 (17:17 -0600)
src/gallium/drivers/llvmpipe/lp_setup.c

index 1a2cd55b164f4fd081b84987beca0520c36d381b..d800b7b05af6fc03962d18867a1e4ab24f111c82 100644 (file)
@@ -644,16 +644,19 @@ lp_setup_update_state( struct lp_setup_context *setup )
 
       stored = lp_scene_alloc_aligned(scene, 4 * 16, 16);
 
-      /* smear each blend color component across 16 ubyte elements */
-      for (i = 0; i < 4; ++i) {
-         uint8_t c = float_to_ubyte(setup->blend_color.current.color[i]);
-         for (j = 0; j < 16; ++j)
-            stored[i*16 + j] = c;
-      }
+      if (stored) {
+         /* smear each blend color component across 16 ubyte elements */
+         for (i = 0; i < 4; ++i) {
+            uint8_t c = float_to_ubyte(setup->blend_color.current.color[i]);
+            for (j = 0; j < 16; ++j)
+               stored[i*16 + j] = c;
+         }
 
-      setup->blend_color.stored = stored;
+         setup->blend_color.stored = stored;
+
+         setup->fs.current.jit_context.blend_color = setup->blend_color.stored;
+      }
 
-      setup->fs.current.jit_context.blend_color = setup->blend_color.stored;
       setup->dirty |= LP_SETUP_NEW_FS;
    }
 
@@ -662,17 +665,19 @@ lp_setup_update_state( struct lp_setup_context *setup )
 
       stored = lp_scene_alloc_aligned(scene, 4 * sizeof(int32_t), 16);
 
-      stored[0] = (float) setup->scissor.current.minx;
-      stored[1] = (float) setup->scissor.current.miny;
-      stored[2] = (float) setup->scissor.current.maxx;
-      stored[3] = (float) setup->scissor.current.maxy;
+      if (stored) {
+         stored[0] = (float) setup->scissor.current.minx;
+         stored[1] = (float) setup->scissor.current.miny;
+         stored[2] = (float) setup->scissor.current.maxx;
+         stored[3] = (float) setup->scissor.current.maxy;
 
-      setup->scissor.stored = stored;
+         setup->scissor.stored = stored;
 
-      setup->fs.current.jit_context.scissor_xmin = stored[0];
-      setup->fs.current.jit_context.scissor_ymin = stored[1];
-      setup->fs.current.jit_context.scissor_xmax = stored[2];
-      setup->fs.current.jit_context.scissor_ymax = stored[3];
+         setup->fs.current.jit_context.scissor_xmin = stored[0];
+         setup->fs.current.jit_context.scissor_ymin = stored[1];
+         setup->fs.current.jit_context.scissor_xmax = stored[2];
+         setup->fs.current.jit_context.scissor_ymax = stored[3];
+      }
 
       setup->dirty |= LP_SETUP_NEW_FS;
    }