From d0aa9f9a344980939e9064400a381a2e145cc08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 13 Oct 2014 15:58:56 +0100 Subject: [PATCH] encodebin: fix some leaks in error code path Fixes test_encodebin_sink_pads_nopreset_static running under valgrind. --- gst/encoding/gstencodebin.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gst/encoding/gstencodebin.c b/gst/encoding/gstencodebin.c index d1ce16954a..3a88603548 100644 --- a/gst/encoding/gstencodebin.c +++ b/gst/encoding/gstencodebin.c @@ -317,6 +317,7 @@ static gboolean gst_encode_bin_setup_profile (GstEncodeBin * ebin, static StreamGroup *_create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, const gchar * sinkpadname, GstCaps * sinkcaps); static void stream_group_remove (GstEncodeBin * ebin, StreamGroup * sgroup); +static void stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup); static GstPad *gst_encode_bin_request_pad_signal (GstEncodeBin * encodebin, GstCaps * caps); static GstPad *gst_encode_bin_request_profile_pad_signal (GstEncodeBin * @@ -1585,7 +1586,8 @@ cleanup: gst_caps_unref (format); if (restriction) gst_caps_unref (restriction); - g_slice_free (StreamGroup, sgroup); + stream_group_free (ebin, sgroup); + g_list_free (tosync); return NULL; } @@ -1920,7 +1922,7 @@ release_pads (const GValue * item, GstElement * elt) gst_element_release_request_pad (elt, pad); } -static void inline +static void stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup) { GList *tmp; @@ -1929,7 +1931,8 @@ stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup) GST_DEBUG_OBJECT (ebin, "Freeing StreamGroup %p", sgroup); - g_signal_handler_disconnect (sgroup->profile, sgroup->restriction_sid); + if (sgroup->restriction_sid != 0) + g_signal_handler_disconnect (sgroup->profile, sgroup->restriction_sid); if (ebin->muxer) { /* outqueue - Muxer */ @@ -1972,8 +1975,12 @@ stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup) } /* Sink Ghostpad */ - if (sgroup->ghostpad) - gst_element_remove_pad (GST_ELEMENT_CAST (ebin), sgroup->ghostpad); + if (sgroup->ghostpad) { + if (GST_PAD_PARENT (sgroup->ghostpad) != NULL) + gst_element_remove_pad (GST_ELEMENT_CAST (ebin), sgroup->ghostpad); + else + gst_object_unref (sgroup->ghostpad); + } if (sgroup->inqueue) gst_element_set_state (sgroup->inqueue, GST_STATE_NULL);