From eb07c4e6b3587f9f5299a8c97f2e16ef2ac8fa6c Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Wed, 4 Dec 2024 16:10:46 +0000 Subject: [PATCH] rtpsession: Fix twcc stats structure leaks Part-of: --- .../gst-plugins-good/gst/rtpmanager/gstrtpsession.c | 2 ++ subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.c | 8 ++++++-- subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.h | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpsession.c b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpsession.c index 760144f51a..15dc2fc2d2 100644 --- a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpsession.c +++ b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpsession.c @@ -3007,6 +3007,8 @@ gst_rtp_session_notify_twcc (RTPSession * sess, event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, twcc_packets); gst_pad_push_event (send_rtp_sink, event); gst_object_unref (send_rtp_sink); + } else { + gst_structure_free (twcc_packets); } g_object_notify (G_OBJECT (rtpsession), "twcc-stats"); diff --git a/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.c b/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.c index 73431aec18..5e767fda5d 100644 --- a/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.c +++ b/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.c @@ -3002,8 +3002,12 @@ rtp_session_process_twcc (RTPSession * sess, guint32 sender_ssrc, RTP_SESSION_UNLOCK (sess); if (sess->callbacks.notify_twcc) - sess->callbacks.notify_twcc (sess, twcc_packets_s, twcc_stats_s, - sess->notify_twcc_user_data); + sess->callbacks.notify_twcc (sess, g_steal_pointer (&twcc_packets_s), + g_steal_pointer (&twcc_stats_s), sess->notify_twcc_user_data); + else { + gst_structure_free (twcc_packets_s); + gst_structure_free (twcc_stats_s); + } RTP_SESSION_LOCK (sess); } diff --git a/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.h b/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.h index d91fa4ac4d..79f0b1f2fb 100644 --- a/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.h +++ b/subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.h @@ -159,6 +159,9 @@ typedef void (*RTPSessionNotifyNACK) (RTPSession *sess, /** * RTPSessionNotifyTWCC: + * @sess: an #RTPSession + * @twcc_packets: (transfer full): TWCC packets #GstStructure + * @twcc_stats: (transfer full): TWCC stats #GstStructure * @user_data: user data specified when registering * * Notifies of Transport-wide congestion control packets and stats.