diff options
author | Mark Michelson <mmichelson@digium.com> | 2015-09-02 17:26:14 -0500 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2015-09-02 17:28:18 -0500 |
commit | c15d8cc0ed110ace9e85cce0857524358139c075 (patch) | |
tree | a639302dc63d9e444950b08a468da8ba782ef0b5 | |
parent | b51cf1e71225b8e368e062be4c94f97b4af70453 (diff) |
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
-rw-r--r-- | res/res_pjsip.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 479b8863f..b8463cecd 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -3736,6 +3736,14 @@ int ast_sip_send_stateful_response(pjsip_rx_data *rdata, pjsip_tx_data *tdata, s 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; } |