From 89e2a69d3792a16b8274ce95d910b131d618e9a4 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 2 Jul 2013 10:56:40 -0400 Subject: [PATCH] clip: Avoid list corruption when grouping objects We are currently iterating over a list that is modified in the same method, we have to get a copy of the list, and iterate over the copy. --- ges/ges-clip.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ges/ges-clip.c b/ges/ges-clip.c index dbf3a557ad..2ceef383f7 100644 --- a/ges/ges-clip.c +++ b/ges/ges-clip.c @@ -546,20 +546,18 @@ _group (GList * containers) supported_formats = GES_CLIP (ret)->priv->supportedformats; for (tmpclip = containers->next; tmpclip; tmpclip = tmpclip->next) { GESClip *cclip = tmpclip->data; + GList *children = ges_container_get_children (GES_CONTAINER (cclip)); - for (tmpelement = GES_CONTAINER_CHILDREN (cclip); tmpelement; - tmpelement = tmpelement->next) { + for (tmpelement = children; tmpelement; tmpelement = tmpelement->next) { GESTimelineElement *celement = GES_TIMELINE_ELEMENT (tmpelement->data); - /* We need to bump the refcount to avoid the object to be destroyed */ - gst_object_ref (celement); ges_container_remove (GES_CONTAINER (cclip), celement); ges_container_add (ret, celement); - gst_object_unref (celement); supported_formats = supported_formats | ges_track_element_get_track_type (GES_TRACK_ELEMENT (celement)); } + g_list_free_full (children, gst_object_unref); ges_layer_remove_clip (layer, tmpclip->data); }