]> 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 14:55:14 +0000 (09:55 -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 2c4617033743667136cfc47817657bb06354f5a7..7581ac5275c5475d1ca57bcd8ec219fb950bde7b 100644 (file)
@@ -5148,7 +5148,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 */