mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 16:52:42 +00:00
input-selector: Take the object lock while iterating sinkpads
Otherwise we can race with pad removal and crash from use-after-free. Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1717 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3747>
This commit is contained in:
parent
2c503a8d7d
commit
e5ddd94da6
1 changed files with 14 additions and 3 deletions
|
@ -493,18 +493,21 @@ static gboolean
|
|||
gst_input_selector_all_eos (GstInputSelector * sel)
|
||||
{
|
||||
GList *walk;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
GST_OBJECT_LOCK (sel);
|
||||
for (walk = GST_ELEMENT_CAST (sel)->sinkpads; walk; walk = walk->next) {
|
||||
GstSelectorPad *selpad;
|
||||
|
||||
selpad = GST_SELECTOR_PAD_CAST (walk->data);
|
||||
if (!selpad->eos) {
|
||||
return FALSE;
|
||||
ret = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
GST_OBJECT_UNLOCK (sel);
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -845,6 +848,7 @@ gst_input_selector_debug_cached_buffers (GstInputSelector * sel)
|
|||
if (gst_debug_category_get_threshold (input_selector_debug) < GST_LEVEL_DEBUG)
|
||||
return;
|
||||
|
||||
GST_OBJECT_LOCK (sel);
|
||||
for (walk = GST_ELEMENT_CAST (sel)->sinkpads; walk; walk = walk->next) {
|
||||
GstSelectorPad *selpad;
|
||||
GString *timestamps;
|
||||
|
@ -866,6 +870,7 @@ gst_input_selector_debug_cached_buffers (GstInputSelector * sel)
|
|||
GST_DEBUG_OBJECT (selpad, "%s", timestamps->str);
|
||||
g_string_free (timestamps, TRUE);
|
||||
}
|
||||
GST_OBJECT_UNLOCK (sel);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -912,6 +917,8 @@ gst_input_selector_cleanup_old_cached_buffers (GstInputSelector * sel,
|
|||
return;
|
||||
|
||||
GST_DEBUG_OBJECT (sel, "Cleaning up old cached buffers");
|
||||
|
||||
GST_OBJECT_LOCK (sel);
|
||||
for (walk = GST_ELEMENT_CAST (sel)->sinkpads; walk; walk = g_list_next (walk)) {
|
||||
GstSelectorPad *selpad;
|
||||
GstSelectorPadCachedBuffer *cached_buffer;
|
||||
|
@ -975,6 +982,7 @@ gst_input_selector_cleanup_old_cached_buffers (GstInputSelector * sel,
|
|||
selpad->cached_buffers = NULL;
|
||||
}
|
||||
}
|
||||
GST_OBJECT_UNLOCK (sel);
|
||||
|
||||
#if DEBUG_CACHED_BUFFERS
|
||||
gst_input_selector_debug_cached_buffers (sel);
|
||||
|
@ -1865,6 +1873,7 @@ gst_input_selector_reset (GstInputSelector * sel)
|
|||
sel->eos_sent = FALSE;
|
||||
|
||||
/* reset each of our sinkpads state */
|
||||
GST_OBJECT_LOCK (sel);
|
||||
for (walk = GST_ELEMENT_CAST (sel)->sinkpads; walk; walk = g_list_next (walk)) {
|
||||
GstSelectorPad *selpad = GST_SELECTOR_PAD_CAST (walk->data);
|
||||
|
||||
|
@ -1875,6 +1884,8 @@ gst_input_selector_reset (GstInputSelector * sel)
|
|||
selpad->tags = NULL;
|
||||
}
|
||||
}
|
||||
GST_OBJECT_UNLOCK (sel);
|
||||
|
||||
sel->have_group_id = TRUE;
|
||||
GST_INPUT_SELECTOR_UNLOCK (sel);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue