OSDN Git Service

auxiliary: fix util_framebuffer_copy
authorLuca Barbieri <luca@luca-barbieri.com>
Fri, 6 Aug 2010 09:08:45 +0000 (11:08 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Wed, 11 Aug 2010 14:27:57 +0000 (16:27 +0200)
util_framebuffer_copy was attempting to copy all elements of the
source framebuffer state.

However, this breaks if the user does not zero initialize the structure.
Instead, only copy the elements up to nr_cbufs, and clear elements up
to dst->nr_cbufs, if the destination was larger than the source.

src/gallium/auxiliary/util/u_framebuffer.c

index 768ae9c..7803ec6 100644 (file)
@@ -85,9 +85,11 @@ util_copy_framebuffer_state(struct pipe_framebuffer_state *dst,
    dst->width = src->width;
    dst->height = src->height;
 
-   for (i = 0; i < Elements(src->cbufs); i++) {
+   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++)
+      pipe_surface_reference(&dst->cbufs[i], NULL);
 
    dst->nr_cbufs = src->nr_cbufs;