[asterisk-commits] res pjsip: Fix contact refleak on stateful responses. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 2 18:14:55 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: res_pjsip: Fix contact refleak on stateful responses.
......................................................................


res_pjsip: Fix contact refleak on stateful responses.

When sending a stateful response, creation of the transaction can fail,
most commonly because we are trying to create a transaction from a
retransmitted request. When creation of the transaction fails, we end up
leaking a reference to a contact that was bumped when the response was
created.

This patch adds the missing deref and fixes the reference leak.

Change-Id: I2f97ad512aeb1b17e87ca29ae0abacb4d6395f07
---
M res/res_pjsip.c
1 file changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 479b886..b8463ce 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3736,6 +3736,14 @@
 	pjsip_transaction *tsx;
 
 	if (pjsip_tsx_create_uas(NULL, rdata, &tsx) != PJ_SUCCESS) {
+		struct ast_sip_contact *contact;
+
+		/* ast_sip_create_response bumps the refcount of the contact and adds it to the tdata.
+		 * We'll leak that reference if we don't get rid of it here.
+		 */
+		contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
+		ao2_cleanup(contact);
+		ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
 		pjsip_tx_data_dec_ref(tdata);
 		return -1;
 	}

-- 
To view, visit https://gerrit.asterisk.org/1178
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2f97ad512aeb1b17e87ca29ae0abacb4d6395f07
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-commits mailing list