osmesa: fix renderbuffer memleak in OSMesaMakeCurrent()
authorBrian Paul <brianp@vmware.com>
Sat, 30 Oct 2010 16:10:52 +0000 (10:10 -0600)
committerBrian Paul <brianp@vmware.com>
Sat, 30 Oct 2010 16:11:37 +0000 (10:11 -0600)
Fixes fd.o bug 31128.

src/mesa/drivers/osmesa/osmesa.c

index 37dc35cbedd72676839467bca7a39af1b4bbb768..10ba6b793144d984e1008f5d799609260228aa9c 100644 (file)
@@ -1327,10 +1327,12 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
     * that converts rendering from CHAN_BITS to the user-requested channel
     * size.
     */
-   osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type);
-   _mesa_remove_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT);
-   _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb);
-   assert(osmesa->rb->RefCount == 2);
+   if (!osmesa->rb) {
+      osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type);
+      _mesa_remove_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT);
+      _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb);
+      assert(osmesa->rb->RefCount == 2);
+   }
 
    /* Set renderbuffer fields.  Set width/height = 0 to force 
     * osmesa_renderbuffer_storage() being called by _mesa_resize_framebuffer()