From cfb1b7951617b2c8dd35c3ccdd3feec6765321a7 Mon Sep 17 00:00:00 2001 From: Alex Ashley Date: Fri, 22 Jan 2016 16:43:03 +0000 Subject: [PATCH] adaptivedemux: fix leak of stream->internal_pad 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index c02ad3e24a..91d0be56e3 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -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);