From: Nicolas Dufresne Date: Tue, 3 Sep 2019 17:44:24 +0000 (-0400) Subject: bin: Fix minor race when adding to a bin X-Git-Tag: 1.16.2~22 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fgstreamer.git;a=commitdiff_plain;h=94ba1cea88788fd3ad72fadcc2ceb7884ed6df50;ds=sidebyside 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. --- diff --git a/gst/gstbin.c b/gst/gstbin.c index e5d4ecd..8e43d3f 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1122,11 +1122,15 @@ 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)); - 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); - gst_object_unref (parent); - g_object_unref (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); + gst_object_unref (parent); + g_object_unref (e); + } } } gst_iterator_free (it);