From 54bf10427402c9ac046ea694e6b48d3d976d55e1 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Wed, 18 Jan 2017 14:59:18 +1100 Subject: [PATCH] decodebin: Don't leak blocked pad references on errors When the decodebin state change fails because of an error message, we might not go through PAUSED->READY. Don't leak a ref to decodebin pads due to pad blocking in that case. This is because we return ASYNC going to PAUSED, and if we fail before reaching PAUSED the only transition we'll see is READY->NULL. https://bugzilla.gnome.org/show_bug.cgi?id=775893 --- gst/playback/gstdecodebin2.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 0a14597867..7e577bf5dd 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -321,6 +321,7 @@ static gboolean gst_decode_bin_remove_element (GstBin * bin, static gboolean check_upstream_seekable (GstDecodeBin * dbin, GstPad * pad); static GstCaps *get_pad_caps (GstPad * pad); +static void unblock_pads (GstDecodeBin * dbin); #define EXPOSE_LOCK(dbin) G_STMT_START { \ GST_LOG_OBJECT (dbin, \ @@ -1128,6 +1129,8 @@ gst_decode_bin_dispose (GObject * object) g_list_free (decode_bin->subtitles); decode_bin->subtitles = NULL; + unblock_pads (decode_bin); + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -5188,19 +5191,20 @@ unblock_pads (GstDecodeBin * dbin) GstPad *opad; opad = gst_ghost_pad_get_target (GST_GHOST_PAD_CAST (dpad)); - if (!opad) - continue; + if (opad) { - GST_DEBUG_OBJECT (dpad, "unblocking"); - if (dpad->block_id != 0) { - gst_pad_remove_probe (opad, dpad->block_id); - dpad->block_id = 0; + GST_DEBUG_OBJECT (dpad, "unblocking"); + if (dpad->block_id != 0) { + gst_pad_remove_probe (opad, dpad->block_id); + dpad->block_id = 0; + } + gst_object_unref (opad); } + dpad->blocked = FALSE; /* make flushing, prevent NOT_LINKED */ gst_pad_set_active (GST_PAD_CAST (dpad), FALSE); gst_object_unref (dpad); - gst_object_unref (opad); GST_DEBUG_OBJECT (dpad, "unblocked"); } @@ -5319,6 +5323,7 @@ gst_decode_bin_change_state (GstElement * element, GstStateChange transition) G_CALLBACK (type_found), dbin); break; case GST_STATE_CHANGE_PAUSED_TO_READY: + case GST_STATE_CHANGE_READY_TO_NULL: if (dbin->have_type_id) g_signal_handler_disconnect (dbin->typefind, dbin->have_type_id); dbin->have_type_id = 0;