autoconvert: Fix race condition when creating sub elements

There was a case where the element would get destroyed while being
added to the hash table of elements

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6989>
This commit is contained in:
Thibault Saunier 2024-02-14 09:43:35 -03:00 committed by GStreamer Marge Bot
parent c14a2d7d6d
commit 11f96ce4dd

View file

@ -500,13 +500,12 @@ gst_base_auto_convert_add_element (GstBaseAutoConvert * self,
g_assert (filter_info->subbin);
element = filter_info->subbin;
element = gst_object_ref (filter_info->subbin);
GST_DEBUG_OBJECT (self, "Adding element %s to the baseautoconvert bin",
filter_info->name);
pads = internal_pads_new (self, GST_OBJECT_NAME (element));
g_hash_table_insert (self->elements, element, pads);
g_hash_table_insert (self->elements, element, internal_pads_ref (pads));
gst_pad_set_chain_function (pads->sink,
GST_DEBUG_FUNCPTR (gst_base_auto_convert_internal_sink_chain));
@ -522,7 +521,9 @@ gst_base_auto_convert_add_element (GstBaseAutoConvert * self,
gst_pad_set_query_function (pads->src,
GST_DEBUG_FUNCPTR (gst_base_auto_convert_internal_src_query));
return gst_object_ref (element);
internal_pads_unref (pads);
return element;
}
static GstElement *