From f63b80748fdbdfbf2d858bed7cdf861a98238088 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 21 Jan 2026 17:12:10 +0100 Subject: [PATCH] MT#59962 AmB2BSession: properly clean RTP streams Properly place the clear RTP receivers handler. Instead of doing directly from the destructor, do it on state change (onBeforeDestroy) via the down to up virtual function realization search. Is triggered by `AmSession::finalize()`. Closes Coverity CID 642748. Change-Id: I4c224425e9fbecedef3d29a6658f1723313b19c4 --- apps/sbc/SBCCallLeg.cpp | 6 +++++- core/AmB2BSession.cpp | 7 ++++++- core/AmB2BSession.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/sbc/SBCCallLeg.cpp b/apps/sbc/SBCCallLeg.cpp index 577966ad..7c91d58c 100644 --- a/apps/sbc/SBCCallLeg.cpp +++ b/apps/sbc/SBCCallLeg.cpp @@ -605,8 +605,12 @@ SBCCallLeg::~SBCCallLeg() void SBCCallLeg::onBeforeDestroy() { for (vector::iterator i = cc_ext.begin(); i != cc_ext.end(); ++i) { - (*i)->onDestroyLeg(this); + try { + (*i)->onDestroyLeg(this); + } + catch (...) { /* ignore errors */ } } + CallLeg::onBeforeDestroy(); } UACAuthCred* SBCCallLeg::getCredentials() { diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index 30d248ed..f5000601 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -116,10 +116,15 @@ AmB2BSession::AmB2BSession(const string& other_local_tag, AmSipDialog* p_dlg, if(!subs) subs = new AmSipSubscription(dlg,this); } -AmB2BSession::~AmB2BSession() +void AmB2BSession::onBeforeDestroy() { + // cleanup before the instance is destroyed clearRtpReceiverRelay(); + AmSession::onBeforeDestroy(); +} +AmB2BSession::~AmB2BSession() +{ ILOG_DLG(L_DBG, "relayed_req.size() = %zu\n",relayed_req.size()); map::iterator it = recvd_req.begin(); diff --git a/core/AmB2BSession.h b/core/AmB2BSession.h index 5720f646..410166ee 100644 --- a/core/AmB2BSession.h +++ b/core/AmB2BSession.h @@ -342,6 +342,8 @@ private: virtual ~AmB2BSession(); + virtual void onBeforeDestroy(); + /** flag to enable RTP relay mode */ RTPRelayMode rtp_relay_mode; /** force symmetric RTP */