MT#59962 CallLeg: `replaceExistingLeg()` use smart ptr

Use smart pointers instead of handling with new/delete.

Fixes:

    Resource leak (RESOURCE_LEAK)
    leaked_storage: Variable rev going out of scope leaks the storage it points to.

Change-Id: I33dfe6c4a74a01774093dc500248c3ed613b5710
mr13.3.1
Donat Zenichev 10 months ago
parent 4750c4b727
commit 326430ecf0

@ -1552,11 +1552,14 @@ void CallLeg::replaceExistingLeg(const string &session_tag, const string &hdrs)
}
else b.media_session = NULL;
ReconnectLegEvent *rev = new ReconnectLegEvent(a_leg ? ReconnectLegEvent::B : ReconnectLegEvent::A, getLocalTag(), hdrs, dlg->established_body);
auto rev = std::make_unique<ReconnectLegEvent>(a_leg ? ReconnectLegEvent::B : ReconnectLegEvent::A, getLocalTag(), hdrs, dlg->established_body);
rev->setMedia(b.media_session, rtp_relay_mode);
ReplaceLegEvent *ev = new ReplaceLegEvent(getLocalTag(), rev);
auto ev = std::make_unique<ReplaceLegEvent>(getLocalTag(), rev.release());
// TODO: what about the RTP relay and other settings? send them as well?
if (!AmSessionContainer::instance()->postEvent(session_tag, ev)) {
if (!AmSessionContainer::instance()->postEvent(session_tag, ev.release())) {
// session doesn't exist - can't connect
ILOG_DLG(L_INFO, "the call leg to be replaced (%s) doesn't exist\n", session_tag.c_str());
if (b.media_session) {

Loading…
Cancel
Save