From 2c0a4d20d4c75bf2cfdc03d18321241221421561 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 22 Jul 2016 14:35:17 +0200 Subject: [PATCH] decodebin3: fix collection refcounting My collection leak fix 83f30627cd9460157935e7e9603c60a15555967e introduced a crash in this scenario: audiotestsrc ! decodebin3 ! fakesink The reference handling of collection in decodebin3 wasn't very clear and my attempt to fix the leak introduced a regression where we went one reference short in some other scenarios. Fixing this by: - Giving a strong reference to DecodebinInput making things clearer - Fixing get_merged_collection() which was sometimes returning an existing reference and sometimes a new one. https://bugzilla.gnome.org/show_bug.cgi?id=769080 --- gst/playback/gstdecodebin3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gst/playback/gstdecodebin3.c b/gst/playback/gstdecodebin3.c index 461659610a..ba17acf4a8 100644 --- a/gst/playback/gstdecodebin3.c +++ b/gst/playback/gstdecodebin3.c @@ -819,6 +819,8 @@ free_input (GstDecodebin3 * dbin, DecodebinInput * input) gst_object_unref (input->parsebin); gst_object_unref (input->parsebin_sink); } + if (input->collection) + gst_object_unref (input->collection); g_free (input); } @@ -1033,7 +1035,7 @@ get_merged_collection (GstDecodebin3 * dbin) if (!needs_merge) { GST_DEBUG_OBJECT (dbin, "No need to merge, returning %p", res); - return res; + return gst_object_ref (res); } /* We really need to create a new collection */ @@ -1142,7 +1144,7 @@ handle_stream_collection (GstDecodebin3 * dbin, /* Replace collection in input */ if (input->collection) gst_object_unref (input->collection); - input->collection = collection; + input->collection = gst_object_ref (collection); GST_DEBUG_OBJECT (dbin, "Setting collection %p on input %p", collection, input);