From e8941a5b2416ab1b4659be897208417ef04da49c Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 25 Apr 2025 14:14:48 +0200 Subject: [PATCH] MT#59962 ModConference: do not leave allocated chan If a channel has been allocated with `ConferenceJoinChannel()` then remember to transfer the ownership over it to the DSM sessions's "garbage collector" which later takes care to deallocate it. Fixes: CID 542153: (#1 of 1): Resource leak (RESOURCE_LEAK) 10. leaked_storage: Variable chan going out of scope leaks the storage it points to. Change-Id: Icdc2c67cf2a349ec70fd83f1cf6a43ecfcf69547 --- apps/dsm/mods/mod_conference/ModConference.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/dsm/mods/mod_conference/ModConference.cpp b/apps/dsm/mods/mod_conference/ModConference.cpp index 7e579cb1..6c0bb660 100644 --- a/apps/dsm/mods/mod_conference/ModConference.cpp +++ b/apps/dsm/mods/mod_conference/ModConference.cpp @@ -229,7 +229,15 @@ EXEC_ACTION_START(ConfRejoinAction) { } if (ConferenceJoinChannel(&chan, sess, sc_sess, channel_id, mode)) { - sc_sess->CLR_ERRNO; + /* save channel for later use */ + AmArg c_arg; + c_arg.setBorrowedPointer(chan); + sc_sess->avar[CONF_AKEY_CHANNEL] = std::move(c_arg); + + /* add to garbage collector */ + sc_sess->transferOwnership(chan); + + sc_sess->CLR_ERRNO; } else { sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG); }