videobuffer: fix memory leak for surface and image.
authorWind Yuan <feng.yuan@intel.com>
Tue, 30 Oct 2012 05:15:45 +0000 (13:15 +0800)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 19 Nov 2012 10:22:03 +0000 (11:22 +0100)
Fix reference leak of surface and image in GstVaapiVideoBuffer wrapper,
thus resulting on actual memory leak of GstVaapiImage when using them
for downloads/uploads from VA surfaces and more specifically surfaces
when the pipeline is shutdown. i.e. vaTerminate() was never called
because the resources were not unreferenced, and thus not deallocated
in the end.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
NEWS
gst-libs/gst/vaapi/gstvaapivideobuffer.c

diff --git a/NEWS b/NEWS
index 43c7e29..64b58ff 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Copyright (C) 2011 Collabora
 
 Version 0.5.0 - DD.Dec.2012
 * Require glib >= 2.31.2
+* Fix memory leak in GstVaapiVideoBuffer for images and surfaces (Feng Yuan)
 
 Version 0.4.1 - 20.Nov.2012
 * Add support for H.264 interlaced streams
index 0a10853..cd1c948 100644 (file)
@@ -86,8 +86,7 @@ gst_vaapi_video_buffer_destroy_image(GstVaapiVideoBuffer *buffer)
     if (priv->image) {
         if (priv->image_pool)
             gst_vaapi_video_pool_put_object(priv->image_pool, priv->image);
-        else
-            g_object_unref(priv->image);
+        g_object_unref(priv->image);
         priv->image = NULL;
     }
 
@@ -104,8 +103,7 @@ gst_vaapi_video_buffer_destroy_surface(GstVaapiVideoBuffer *buffer)
     if (priv->surface) {
         if (priv->surface_pool)
             gst_vaapi_video_pool_put_object(priv->surface_pool, priv->surface);
-        else
-            g_object_unref(priv->surface);
+        g_object_unref(priv->surface);
         priv->surface = NULL;
     }