From 58479bec37d50662bb4f709b74bf4bffcfe75c10 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Tue, 27 Aug 2019 15:14:31 +0200 Subject: [PATCH] sdp: don't leak the ghost pad The peer is already gone when pad_removed_cb() called, so the ghost cannot be removed. Use g_object_set_data() instead to remember the ghost pad. Copied from similar code in GstRTPBin. --- gst/sdp/gstsdpsrc.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/gst/sdp/gstsdpsrc.c b/gst/sdp/gstsdpsrc.c index ea9a5bcd17..6945df559b 100644 --- a/gst/sdp/gstsdpsrc.c +++ b/gst/sdp/gstsdpsrc.c @@ -110,26 +110,21 @@ pad_added_cb (GstElement * element, GstPad * pad, gpointer user_data) gst_static_pad_template_get (&src_template)); gst_pad_set_active (ghost, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (self), ghost); + g_object_set_data (G_OBJECT (pad), "GstSdpSrc.ghostpad", ghost); } static void pad_removed_cb (GstElement * element, GstPad * pad, gpointer user_data) { GstSdpSrc *self = GST_SDP_SRC_CAST (user_data); - GstPad *peer; - - peer = gst_pad_get_peer (pad); - if (peer) { - GstPad *ghost = - GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (peer))); + GstPad *ghost; - if (ghost) { - gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (ghost), NULL); - gst_element_remove_pad (GST_ELEMENT_CAST (self), ghost); - gst_object_unref (ghost); - } + ghost = g_object_get_data (G_OBJECT (pad), "GstSdpSrc.ghostpad"); + if (ghost) { + g_object_set_data (G_OBJECT (pad), "GstSdpSrc.ghostpad", NULL); - gst_object_unref (peer); + gst_pad_set_active (ghost, FALSE); + gst_element_remove_pad (GST_ELEMENT_CAST (self), ghost); } } -- 2.34.1