]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_session: Fix session reference leak.
authorJoshua C. Colp <jcolp@sangoma.com>
Tue, 22 Sep 2020 10:13:32 +0000 (07:13 -0300)
committerJoshua Colp <jcolp@sangoma.com>
Wed, 23 Sep 2020 15:01:38 +0000 (10:01 -0500)
The ast_sip_dialog_get_session function returns the session
with reference count increased. This was not taken into
account and was causing sessions to remain around when they
should not be.

ASTERISK-29089

Change-Id: I430fa721b0a824311a59effec6056e9ec528e3e8

res/res_pjsip_session.c

index 19e0528e83b318791b4be6be4afc662e232fef5b..009111373c9a310810ce65ae0b72d58a8cd1e72f 100644 (file)
@@ -5238,7 +5238,7 @@ static void session_outgoing_nat_hook(pjsip_tx_data *tdata, struct ast_sip_trans
                tdata->mod_data, session_module.id, MOD_DATA_NAT_HOOK);
        struct pjmedia_sdp_session *sdp;
        pjsip_dialog *dlg = pjsip_tdata_get_dlg(tdata);
-       struct ast_sip_session *session = dlg ? ast_sip_dialog_get_session(dlg) : NULL;
+       RAII_VAR(struct ast_sip_session *, session, dlg ? ast_sip_dialog_get_session(dlg) : NULL, ao2_cleanup);
        int stream;
 
        /* SDP produced by us directly will never be multipart */