[totem] Bug 595529 - Screenshot cause memory leakage



commit a71822e5db8c2bb78d5b970779a39e59ef3cc81c
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Sep 21 16:15:09 2009 +0100

    Bug 595529 - Screenshot cause memory leakage
    
    We take ownership of the buffer, but never actually unref it,
    do this, even on error. With help from Tim.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=595529

 src/backend/gstscreenshot.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/src/backend/gstscreenshot.c b/src/backend/gstscreenshot.c
index 021bf3e..6bdd3f1 100644
--- a/src/backend/gstscreenshot.c
+++ b/src/backend/gstscreenshot.c
@@ -98,13 +98,13 @@ bvw_frame_conv_convert (GstBuffer * buf, GstCaps * to_caps)
       !create_element ("fakesink", &sink, &error)) {
     g_warning ("Could not take screenshot: %s", error->message);
     g_error_free (error);
-    return NULL;
+    goto bail;
   }
 
   pipeline = gst_pipeline_new ("screenshot-pipeline");
   if (pipeline == NULL) {
     g_warning ("Could not take screenshot: %s", "no pipeline (unknown error)");
-    return NULL;
+    goto bail;
   }
 
   GST_DEBUG ("adding elements");
@@ -133,23 +133,23 @@ bvw_frame_conv_convert (GstBuffer * buf, GstCaps * to_caps)
   /* FIXME: linking is still way too expensive, profile this properly */
   GST_DEBUG ("linking src->csp");
   if (!gst_element_link_pads (src, "src", csp, "sink"))
-    return NULL;
+    goto bail;
 
   GST_DEBUG ("linking csp->filter1");
   if (!gst_element_link_pads (csp, "src", filter1, "sink"))
-    return NULL;
+    goto bail;
 
   GST_DEBUG ("linking filter1->vscale");
   if (!gst_element_link_pads (filter1, "src", vscale, "sink"))
-    return NULL;
+    goto bail;
 
   GST_DEBUG ("linking vscale->capsfilter");
   if (!gst_element_link_pads (vscale, "src", filter2, "sink"))
-    return NULL;
+    goto bail;
 
   GST_DEBUG ("linking capsfilter->sink");
   if (!gst_element_link_pads (filter2, "src", sink, "sink"))
-    return NULL;
+    goto bail;
 
   GST_DEBUG ("running conversion pipeline");
   gst_element_set_state (pipeline, GST_STATE_PLAYING);
@@ -194,6 +194,9 @@ bvw_frame_conv_convert (GstBuffer * buf, GstCaps * to_caps)
   gst_element_set_state (pipeline, GST_STATE_NULL);
   gst_object_unref (pipeline);
 
+bail:
+  g_object_unref (buf);
+
   return result;
 }
 



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