multiqueue: Ensure peer pad exists when iterating internal links
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
Thu, 6 May 2021 10:54:46 +0000 (12:54 +0200)
committerJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
Thu, 6 May 2021 11:08:26 +0000 (13:08 +0200)
The pads can be NULL when we're racing with pad removal, e.g. when the
pads get removed between `gst_pad_iterate_internal_links` acquiring the
parent element and `gst_multi_queue_iterate_internal_links` locking the
multiqueue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/810>

plugins/elements/gstmultiqueue.c

index 917fc2fb1247792c35183a9ca1559db25abbe461..bc86999c8e8c458fbb655c3c212598095d5bb281 100644 (file)
@@ -1144,11 +1144,11 @@ gst_multi_queue_iterate_internal_links (GstPad * pad, GstObject * parent)
 
   srcpad = g_weak_ref_get (&squeue->srcpad);
   sinkpad = g_weak_ref_get (&squeue->sinkpad);
-  if (sinkpad == pad) {
+  if (sinkpad == pad && srcpad) {
     opad = srcpad;
     gst_clear_object (&sinkpad);
 
-  } else if (srcpad == pad) {
+  } else if (srcpad == pad && sinkpad) {
     opad = sinkpad;
     gst_clear_object (&srcpad);