Make sure gst_adaptive_demux_loop_cancel_call()
never tries to operate on an invalidated main context. Make
sure to clear the main context pointer while holding the lock,
and to check it in gst_adaptive_demux_loop_cancel_call()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2847>
loop->loop = NULL;
g_cond_broadcast (&loop->cond);
- g_mutex_unlock (&loop->lock);
g_main_context_unref (loop->context);
loop->context = NULL;
+ g_mutex_unlock (&loop->lock);
+
gst_adaptive_demux_loop_unref (loop);
return NULL;
void
gst_adaptive_demux_loop_cancel_call (GstAdaptiveDemuxLoop * loop, guint cb_id)
{
- GSource *s;
g_mutex_lock (&loop->lock);
- s = g_main_context_find_source_by_id (loop->context, cb_id);
- if (s)
- g_source_destroy (s);
+ if (loop->context) {
+ GSource *s = g_main_context_find_source_by_id (loop->context, cb_id);
+ if (s)
+ g_source_destroy (s);
+ }
g_mutex_unlock (&loop->lock);
}