i915g: fix null deref in draw_rect emission
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 25 Feb 2011 22:32:48 +0000 (23:32 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Sat, 26 Feb 2011 14:35:24 +0000 (15:35 +0100)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
src/gallium/drivers/i915/i915_state_emit.c

index 510fb1ccc6365d1a1fd6acff2efbb41e772c20f0..a9a9d7fcb4ec45ec87e3a1d9d3e9e5a5865260f8 100644 (file)
@@ -413,7 +413,6 @@ i915_emit_hardware_state(struct i915_context *i915 )
    {
       uint w, h;
       struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
-      struct i915_texture *tex = i915_texture(cbuf_surface->texture);
       unsigned x, y;
       int layer;
       uint32_t draw_offset;
@@ -422,10 +421,15 @@ i915_emit_hardware_state(struct i915_context *i915 )
       ret = framebuffer_size(&i915->framebuffer, &w, &h);
       assert(ret);
 
-      layer = cbuf_surface->u.tex.first_layer;
+      if (cbuf_surface) {
+        struct i915_texture *tex = i915_texture(cbuf_surface->texture);
+        layer = cbuf_surface->u.tex.first_layer;
+
+        x = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksx;
+        y = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksy;
 
-      x = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksx;
-      y = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksy;
+      } else
+        x = y = 0;
 
       draw_offset = x | (y << 16);