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.
This commit is contained in:
Stian Selnes 2018-05-28 10:57:13 +02:00 committed by Havard Graff
parent 6d16615093
commit 69430dd7ba

View file

@ -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);