i915g: Fix possible null pointer deference in debug builds.
authorVinson Lee <vlee@vmware.com>
Mon, 12 Apr 2010 01:07:41 +0000 (18:07 -0700)
committerVinson Lee <vlee@vmware.com>
Mon, 12 Apr 2010 01:07:41 +0000 (18:07 -0700)
i915_buffer deferences buf in debug builds. Move declaration and
assignment to inside NULL check of buf.

src/gallium/drivers/i915/i915_state.c

index bc2f1b268a0dbab5f47f427e1c20bddbfac6012c..397647204b47aa384c4a46ea4d0cf538765235b9 100644 (file)
@@ -527,7 +527,6 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
                                      struct pipe_resource *buf)
 {
    struct i915_context *i915 = i915_context(pipe);
-   struct i915_buffer *ir = i915_buffer(buf);
    draw_flush(i915->draw);
 
    assert(shader < PIPE_SHADER_TYPES);
@@ -543,6 +542,7 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
     * N constants, leaving any extras from shader translation alone.
     */
    if (buf) {
+      struct i915_buffer *ir = i915_buffer(buf);
       memcpy(i915->current.constants[shader], ir->data, ir->b.b.width0);
       i915->current.num_user_constants[shader] = (ir->b.b.width0 /
                                                  4 * sizeof(float));