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



commit 234706cb83373fffac48e1a02300af567bf1d5d4
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
    (cherry picked from commit 02d14ec15cf5a41aca3208e8d5bce7dab8dd1fe4)
    
    Signed-off-by: Emmanuele Bassi <ebassi linux intel com>

 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 fbe0b45..6fa9f46 100644
--- a/clutter/cogl/cogl/cogl-framebuffer.c
+++ b/clutter/cogl/cogl/cogl-framebuffer.c
@@ -861,7 +861,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);
@@ -897,8 +897,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
@@ -906,6 +910,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]