diff options
author | Kouhei Sutou <kou@clear-code.com> | 2016-09-19 17:04:55 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-09-30 13:40:36 +0300 |
commit | a195e47633967ed09b61ab6f6e270ce9ad04cbb2 (patch) | |
tree | 3bcff7644a5d4161877aa025e6a05a2e6be96e1d | |
parent | b724894b27e2956c01e8198892d8220e16ab2597 (diff) |
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
-rw-r--r-- | gst/gstbin.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gst/gstbin.c b/gst/gstbin.c index 9601b8ebba..49769625be 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1946,14 +1946,24 @@ typedef struct _GstBinSortIterator } 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) { 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) |