util: set all unused cbufs to NULL in util_copy_framebuffer_state()
authorBrian Paul <brianp@vmware.com>
Thu, 7 Nov 2013 23:59:40 +0000 (16:59 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 11 Nov 2013 15:12:18 +0000 (08:12 -0700)
This helps fix an issue in the svga driver, and is just safer all-around.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/util/u_framebuffer.c

index 7803ec6a8b501f77e21f6cfcd612ee7680b05f6a..f84485d1f1c66a20cafa83dc7fe4d4f33b542371 100644 (file)
@@ -88,7 +88,8 @@ util_copy_framebuffer_state(struct pipe_framebuffer_state *dst,
    for (i = 0; i < src->nr_cbufs; i++)
       pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]);
 
-   for (i = src->nr_cbufs; i < dst->nr_cbufs; i++)
+   /* Set remaining dest cbuf pointers to NULL */
+   for ( ; i < Elements(dst->cbufs); i++)
       pipe_surface_reference(&dst->cbufs[i], NULL);
 
    dst->nr_cbufs = src->nr_cbufs;