tee: Lock mutex before reading the removed flag of the pads
authorSebastian Dröge <sebastian@centricular.com>
Thu, 24 Oct 2019 22:39:05 +0000 (01:39 +0300)
committerMathieu Duponchelle <mduponchelle1@gmail.com>
Thu, 24 Oct 2019 22:49:41 +0000 (22:49 +0000)
Otherwise we're not guaranteed to read the very latest value that
another thread might've written in there when the pad was released, and
could instead work with an old value.

plugins/elements/gsttee.c

index f93350941d3886e2e572edd85cec89d2b481dcf9..5b33125900bcf2f84aad11733d8d5d028697c106 100644 (file)
@@ -899,12 +899,14 @@ gst_tee_handle_data (GstTee * tee, gpointer data, gboolean is_list)
       ret = gst_pad_push (pad, GST_BUFFER_CAST (data));
     }
 
+    GST_OBJECT_LOCK (tee);
     if (GST_TEE_PAD_CAST (pad)->removed)
       ret = GST_FLOW_NOT_LINKED;
 
     if (ret == GST_FLOW_NOT_LINKED && tee->allow_not_linked) {
       ret = GST_FLOW_OK;
     }
+    GST_OBJECT_UNLOCK (tee);
 
     gst_object_unref (pad);