From: Brian Paul Date: Sat, 30 Oct 2010 16:10:52 +0000 (-0600) Subject: osmesa: fix renderbuffer memleak in OSMesaMakeCurrent() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c2b4814d0b7dc67777099ea249c09bcf9ee46eb;p=mesa.git osmesa: fix renderbuffer memleak in OSMesaMakeCurrent() Fixes fd.o bug 31128. --- diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 37dc35cbedd..10ba6b79314 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -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()