From e36ae315dc2eb5596282f5cd5f34fe6dba48d345 Mon Sep 17 00:00:00 2001 From: Yeongjin Jeong Date: Fri, 25 Jan 2019 18:21:43 +0900 Subject: [PATCH] video-transition: Fix GstPad leak Returned Gstpad by link_element_to_mixer_with_smpte() has increased refcount in ges_smart_mixer_get_mixer_pad(). --- ges/ges-video-transition.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ges/ges-video-transition.c b/ges/ges-video-transition.c index 61657357db..4c36cca54e 100644 --- a/ges/ges-video-transition.c +++ b/ges/ges-video-transition.c @@ -209,21 +209,20 @@ ges_video_transition_init (GESVideoTransition * self) } static void -release_mixer (GstElement ** mixer, GstPad ** sinka, GstPad ** sinkb) +ges_video_transition_release_mixer (GESVideoTransition * self) { - if (*sinka && *sinkb) { - gst_element_release_request_pad (*mixer, *sinka); - gst_element_release_request_pad (*mixer, *sinkb); - gst_object_unref (*sinka); - gst_object_unref (*sinkb); - *sinka = NULL; - *sinkb = NULL; + GESVideoTransitionPrivate *priv = self->priv; + + if (priv->mixer_ghosta && priv->mixer_ghostb) { + gst_element_release_request_pad (priv->mixer, priv->mixer_ghosta); + gst_element_release_request_pad (priv->mixer, priv->mixer_ghostb); + gst_clear_object (&priv->mixer_ghosta); + gst_clear_object (&priv->mixer_ghostb); } - if (*mixer) { - gst_object_unref (*mixer); - *mixer = NULL; - } + gst_clear_object (&priv->mixer_sinka); + gst_clear_object (&priv->mixer_sinkb); + gst_clear_object (&priv->mixer); } static void @@ -249,7 +248,7 @@ ges_video_transition_dispose (GObject * object) priv->smpte_control_source = NULL; } - release_mixer (&priv->mixer, &priv->mixer_ghosta, &priv->mixer_ghostb); + ges_video_transition_release_mixer (self); g_signal_handlers_disconnect_by_func (GES_TRACK_ELEMENT (self), duration_changed_cb, NULL);