rtpdtmfsrc: fix leak when shutting down mid-event

.. and update rtpdtmfdepay unit test to trigger
the potential leak more reliably (without the fix).

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3633

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7060>
This commit is contained in:
Tim-Philipp Müller 2024-06-19 01:55:57 +01:00 committed by GStreamer Marge Bot
parent c8dfb7c8f0
commit 62047a9f8d
2 changed files with 25 additions and 19 deletions

View file

@ -1084,6 +1084,9 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition)
} }
dtmfsrc->last_event_was_start = FALSE; dtmfsrc->last_event_was_start = FALSE;
// Clear out any unfinished events
g_clear_pointer (&dtmfsrc->payload, g_free);
/* Indicate that we don't do PRE_ROLL */ /* Indicate that we don't do PRE_ROLL */
break; break;

View file

@ -562,6 +562,8 @@ GST_END_TEST;
GST_START_TEST (test_rtpdtmfdepay_src_caps_fixated) GST_START_TEST (test_rtpdtmfdepay_src_caps_fixated)
{ {
// Loop a few times, additional test for rtpdtmfsrc leak on early shutdown
for (int i = 0; i < 50; ++i) {
GstElement *pipeline; GstElement *pipeline;
GstStructure *s; GstStructure *s;
@ -588,6 +590,7 @@ GST_START_TEST (test_rtpdtmfdepay_src_caps_fixated)
gst_element_set_state (pipeline, GST_STATE_NULL); gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline); gst_object_unref (pipeline);
} }
}
GST_END_TEST; GST_END_TEST;