bin: Fix minor race when adding to a bin

This patch simply add a null check around a case where a child may have
been unparented concurrently to the deep_add_remove operation. This was
found by accident in the form of an "IS_GST_OBJECT" assertion, but had
no other known side effect in that test.
This commit is contained in:
Nicolas Dufresne 2019-09-03 13:44:24 -04:00 committed by Tim-Philipp Müller
parent 090a928329
commit 94ba1cea88

View file

@ -1122,6 +1122,9 @@ gst_bin_do_deep_add_remove (GstBin * bin, gint sig_id, const gchar * sig_name,
while ((e = g_queue_pop_head (&elements))) {
GstObject *parent = gst_object_get_parent (GST_OBJECT_CAST (e));
/* an element could have removed some of its internal elements
* meanwhile, so protect against that */
if (parent) {
GST_LOG_OBJECT (bin, "calling %s for element %" GST_PTR_FORMAT
" in bin %" GST_PTR_FORMAT, sig_name, e, parent);
g_signal_emit (bin, sig_id, 0, parent, e);
@ -1129,6 +1132,7 @@ gst_bin_do_deep_add_remove (GstBin * bin, gint sig_id, const gchar * sig_name,
g_object_unref (e);
}
}
}
gst_iterator_free (it);
}
}