From 69430dd7ba070b0996662b4d1b6cd9600037341f Mon Sep 17 00:00:00 2001 From: Stian Selnes Date: Mon, 28 May 2018 10:57:13 +0200 Subject: [PATCH] harness: Make sure pad functions are not called after teardown For the query function there's a risk that the function may be called after the harness has been teared down. Since the function accesses a pointer to the harness via the pad's data, the harness must protect itself against this. Event and chain function is also handled for constistency, although they don't have the same problem since the gstpad.c checks whether the pad is flushing before calling these. --- libs/gst/check/gstharness.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libs/gst/check/gstharness.c b/libs/gst/check/gstharness.c index b2761004a1..af4d2722f4 100644 --- a/libs/gst/check/gstharness.c +++ b/libs/gst/check/gstharness.c @@ -1055,6 +1055,14 @@ gst_harness_teardown (GstHarness * h) g_free (priv->element_sinkpad_name); gst_pad_set_active (h->srcpad, FALSE); + + /* Make sure our funcs are not called after harness is teared down since + * they try to access this harness through pad data */ + GST_PAD_STREAM_LOCK (h->srcpad); + gst_pad_set_event_function (h->srcpad, NULL); + gst_pad_set_query_function (h->srcpad, NULL); + GST_PAD_STREAM_UNLOCK (h->srcpad); + gst_object_unref (h->srcpad); g_async_queue_unref (priv->src_event_queue); @@ -1066,6 +1074,15 @@ gst_harness_teardown (GstHarness * h) g_free (priv->element_srcpad_name); gst_pad_set_active (h->sinkpad, FALSE); + + /* Make sure our funcs are not called after harness is teared down since + * they try to access this harness through pad data */ + GST_PAD_STREAM_LOCK (h->sinkpad); + gst_pad_set_chain_function (h->sinkpad, NULL); + gst_pad_set_event_function (h->sinkpad, NULL); + gst_pad_set_query_function (h->sinkpad, NULL); + GST_PAD_STREAM_UNLOCK (h->sinkpad); + gst_object_unref (h->sinkpad); g_async_queue_unref (priv->buffer_queue);