[clutter] offscreen: Plug a leak in an error path



commit 02d14ec15cf5a41aca3208e8d5bce7dab8dd1fe4
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Mon Apr 4 14:42:36 2011 +0100

    offscreen: Plug a leak in an error path
    
    When creating a CoglOffscreen we take a reference on the texture handle,
    but in case of error we never release it.
    
    We should take that reference only on success.
    
    http://bugzilla.clutter-project.org/show_bug.cgi?id=2620

 clutter/cogl/cogl/cogl-framebuffer.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/clutter/cogl/cogl/cogl-framebuffer.c b/clutter/cogl/cogl/cogl-framebuffer.c
index f006407..d3f1537 100644
--- a/clutter/cogl/cogl/cogl-framebuffer.c
+++ b/clutter/cogl/cogl/cogl-framebuffer.c
@@ -862,7 +862,7 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
   _cogl_texture_set_filters (texhandle, GL_NEAREST, GL_NEAREST);
 
   offscreen = g_new0 (CoglOffscreen, 1);
-  offscreen->texture = cogl_handle_ref (texhandle);
+  offscreen->texture = texhandle;
 
   if ((create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL))
     fbo_created = try_creating_fbo (offscreen, 0, &data);
@@ -898,8 +898,12 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
                               data.level_width,
                               data.level_height);
 
+      /* take a reference on the texture */
+      cogl_handle_ref (offscreen->texture);
+
       ret = _cogl_offscreen_object_new (offscreen);
       _cogl_texture_associate_framebuffer (texhandle, COGL_FRAMEBUFFER (ret));
+
       return ret;
     }
   else
@@ -907,6 +911,7 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
       g_free (offscreen);
       /* XXX: This API should probably have been defined to take a GError */
       g_warning ("%s: Failed to create an OpenGL framebuffer", G_STRLOC);
+
       return COGL_INVALID_HANDLE;
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]