adaptivedemux: fix leak of stream->internal_pad
authorAlex Ashley <alex.ashley@youview.com>
Fri, 22 Jan 2016 16:43:03 +0000 (16:43 +0000)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 22 Jan 2016 17:04:42 +0000 (19:04 +0200)
The function gst_adaptive_demux_stream_update_source() function creates
a new GstPad called internal_pad. This pad is not freed when releasing
the stream.

The solution is to set GST_PAD_FLAG_NEED_PARENT so that the chain
functions do not get called when the pad has no parent and then
remove the parent in the gst_adaptive_demux_stream_free() function. This
causes the refcount of the pad to be set to zero.

https://bugzilla.gnome.org/show_bug.cgi?id=760982

gst-libs/gst/adaptivedemux/gstadaptivedemux.c

index c02ad3e..91d0be5 100644 (file)
@@ -1132,6 +1132,10 @@ gst_adaptive_demux_stream_free (GstAdaptiveDemuxStream * stream)
     stream->pending_events = NULL;
   }
 
+  if (stream->internal_pad) {
+    gst_object_unparent (GST_OBJECT_CAST (stream->internal_pad));
+  }
+
   if (stream->src_srcpad) {
     gst_object_unref (stream->src_srcpad);
     stream->src_srcpad = NULL;
@@ -2293,6 +2297,7 @@ gst_adaptive_demux_stream_update_source (GstAdaptiveDemuxStream * stream,
     g_free (internal_name);
     gst_object_set_parent (GST_OBJECT_CAST (stream->internal_pad),
         GST_OBJECT_CAST (demux));
+    GST_OBJECT_FLAG_SET (stream->internal_pad, GST_PAD_FLAG_NEED_PARENT);
     gst_pad_set_element_private (stream->internal_pad, stream);
     gst_pad_set_active (stream->internal_pad, TRUE);
     gst_pad_set_chain_function (stream->internal_pad, _src_chain);