From a43de49d522178d592c44149fd284418e8314336 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Mon, 19 Sep 2016 10:04:55 -0400 Subject: [PATCH] bin: When copying the sort iterator, also copy its internal queue Otherwise both iterators share the same references, the second one usually resulting in a crash when being freed. https://bugzilla.gnome.org/show_bug.cgi?id=771649 --- gst/gstbin.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gst/gstbin.c b/gst/gstbin.c index a76810e035..28bae6710d 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -2134,6 +2134,16 @@ typedef struct _GstBinSortIterator gboolean dirty; /* we detected structure change */ } GstBinSortIterator; +static void +copy_to_queue (gpointer data, gpointer user_data) +{ + GstElement *element = data; + GQueue *queue = user_data; + + gst_object_ref (element); + g_queue_push_tail (queue, element); +} + static void gst_bin_sort_iterator_copy (const GstBinSortIterator * it, GstBinSortIterator * copy) @@ -2141,8 +2151,8 @@ gst_bin_sort_iterator_copy (const GstBinSortIterator * it, GHashTableIter iter; gpointer key, value; - copy->queue = it->queue; - g_queue_foreach (©->queue, (GFunc) gst_object_ref, NULL); + g_queue_init (©->queue); + g_queue_foreach (&it->queue, copy_to_queue, ©->queue); copy->bin = gst_object_ref (it->bin); if (it->best)