autoconvert: Avoid some leaks in autoconvert
authorbenjamin gaignard <benjamin.gaignard@stericsson>
Mon, 20 Dec 2010 14:33:28 +0000 (15:33 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 21 Dec 2010 16:50:20 +0000 (17:50 +0100)
unref sink and src pad after gst_pad_by_direction calls unref
element if gst_auto_convert_activate_element failed.

See bug #637553.

gst/autoconvert/gstautoconvert.c

index ebe297c..97bd8b4 100644 (file)
@@ -576,6 +576,7 @@ gst_auto_convert_add_element (GstAutoConvert * autoconvert,
   if (!sinkpad) {
     GST_ERROR_OBJECT (autoconvert, "Could not find sink in %s",
         GST_OBJECT_NAME (element));
+    gst_object_unref (srcpad);
     goto error;
   }
 
@@ -652,6 +653,9 @@ gst_auto_convert_add_element (GstAutoConvert * autoconvert,
   /* Increment the reference count we will return to the caller */
   gst_object_ref (element);
 
+  /* unref sink and src pad */
+  gst_object_unref (srcpad);
+  gst_object_unref (sinkpad);
   return element;
 
 error:
@@ -879,6 +883,8 @@ gst_auto_convert_sink_setcaps (GstPad * pad, GstCaps * caps)
     /* And make it the current child */
     if (gst_auto_convert_activate_element (autoconvert, element, caps))
       break;
+    else
+      gst_object_unref (element);
   }
 
 get_out: