tests/input selector: Fix a shutdown crash
authorJan Schmidt <jan@centricular.com>
Wed, 6 May 2020 17:28:59 +0000 (03:28 +1000)
committerJan Schmidt <jan@centricular.com>
Wed, 6 May 2020 17:30:43 +0000 (03:30 +1000)
Hold a ref to the pad we're planning on sending EOS too, so that
it doesn't disappear if things shut down before the thread gets
to actually send the EOS event.

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

tests/check/elements/selector.c

index 0570f13..529c046 100644 (file)
@@ -500,10 +500,12 @@ input_selector_push_buffer (gint stream, enum InputSelectorResult res)
   }
 }
 
+/* Consumes a ref to the passed pad */
 static gpointer
 input_selector_do_push_eos (GstPad * pad)
 {
   gst_pad_push_event (pad, gst_event_new_eos ());
+  gst_object_unref (pad);
   return NULL;
 }
 
@@ -533,7 +535,7 @@ input_selector_push_eos (gint stream, gboolean active)
      * from a separate thread. This makes this test racy, but it should only
      * cause false positives, not false negatives */
     GThread *t = g_thread_new ("selector-test-push-eos",
-        (GThreadFunc) input_selector_do_push_eos, pad);
+        (GThreadFunc) input_selector_do_push_eos, gst_object_ref (pad));
 
     /* Sleep half a second to allow the other thread to execute, this is not
      * a definitive solution but there is no way to know when the