Mesa (master): mesa: fix renderbuffer leak

Timothy Arceri tarceri at kemper.freedesktop.org
Fri Apr 7 09:48:36 UTC 2017


Module: Mesa
Branch: master
Commit: 8046a944d084b4ae4e70e61ba50846fd1943247f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8046a944d084b4ae4e70e61ba50846fd1943247f

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Fri Apr  7 07:55:17 2017 +1000

mesa: fix renderbuffer leak

We don't need to call _mesa_reference_renderbuffer() for the first
assignment as refCount starts at 1. For swrast we work around the
fact we will indirectly call _mesa_reference_renderbuffer() by
resetting refCount to 0.

Fixes: 32141e53d1520 (mesa: tidy up renderbuffer RefCount initialisation)

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>

---

 src/mesa/main/fbobject.c         | 2 +-
 src/mesa/swrast/s_renderbuffer.c | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 3289f86803..d486d01195 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -451,7 +451,7 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture()");
          return;
       }
-      _mesa_reference_renderbuffer(&att->Renderbuffer, rb);
+      att->Renderbuffer = rb;
 
       /* This can't get called on a texture renderbuffer, so set it to NULL
        * for clarity compared to user renderbuffers.
diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
index d8c4ed3863..af09955484 100644
--- a/src/mesa/swrast/s_renderbuffer.c
+++ b/src/mesa/swrast/s_renderbuffer.c
@@ -271,6 +271,11 @@ add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
          return GL_FALSE;
       }
 
+      /* Set refcount to 0 to avoid a leak since the _mesa_add_renderbuffer()
+       * call below will bump the initial refcount.
+       */
+      rb->RefCount = 0;
+
       rb->InternalFormat = GL_RGBA;
 
       rb->AllocStorage = soft_renderbuffer_storage;




More information about the mesa-commit mailing list