From 9c2b4814d0b7dc67777099ea249c09bcf9ee46eb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 30 Oct 2010 10:10:52 -0600 Subject: [PATCH] osmesa: fix renderbuffer memleak in OSMesaMakeCurrent() Fixes fd.o bug 31128. --- src/mesa/drivers/osmesa/osmesa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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() -- 2.30.2