svga: fix referencing a NULL framebuffer cbuf
authorCharmaine Lee <charmainel@vmware.com>
Fri, 21 Aug 2015 18:41:26 +0000 (11:41 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 2 Sep 2015 19:22:42 +0000 (13:22 -0600)
Check for a valid framebuffer cbuf pointer before accessing its
associated surface.

Fix piglit test fbo-drawbuffers-none.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/svga/svga_pipe_sampler.c

index ab84ed396024566d2a5b7b5c7caaddc24aa443a4..60e2d44ace4e23c0b7a3a7bf0fd412f46e89cd75 100644 (file)
@@ -455,8 +455,8 @@ svga_set_sampler_views(struct pipe_context *pipe,
     * for the conflicted surface view.
     */
    for (i = 0; i < svga->curr.framebuffer.nr_cbufs; i++) {
-      struct svga_surface *s = svga_surface(svga->curr.framebuffer.cbufs[i]);
-      if (s) {
+      if (svga->curr.framebuffer.cbufs[i]) {
+         struct svga_surface *s = svga_surface(svga->curr.framebuffer.cbufs[i]);
          if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) {
             svga->dirty |= SVGA_NEW_FRAME_BUFFER;
             break;