From: Kinsey Moore Date: Thu, 26 Apr 2012 13:27:34 +0000 (+0000) Subject: Fix reference leaks involving SIP Replaces transfers X-Git-Tag: 10.5.0-rc1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc90320d1b1604e42d5ab218f43e584bb8b6f4e2;p=thirdparty%2Fasterisk.git Fix reference leaks involving SIP Replaces transfers The reference held for SIP blind transfers using the Replaces header in an INVITE was never freed on success and also failed to be freed in some error conditions. This caused a file descriptor leak since the RTP structures in use at the time of the transfer were never freed. This reference leak and another relating to subscriptions in the same code path have now been corrected. (Closes issue ASTERISK-19579) Reported by: Maciej Krajewski Tested by: Maciej Karjewski ........ Merged revisions 363986 from http://svn.asterisk.org/svn/asterisk/branches/1.8 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@363987 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 46fc831faf..27ee075212 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -5841,8 +5841,12 @@ void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist) } if (p->udptl) ast_udptl_destroy(p->udptl); - if (p->refer) + if (p->refer) { + if (p->refer->refer_call) { + p->refer->refer_call = dialog_unref(p->refer->refer_call, "unref dialog p->refer->refer_call"); + } ast_free(p->refer); + } if (p->route) { free_old_route(p->route); p->route = NULL; @@ -23096,6 +23100,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int if (subscription->owner) { ast_channel_unlock(subscription->owner); } + subscription = dialog_unref(subscription, "unref dialog subscription"); } } @@ -23114,7 +23119,6 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int if (p->refer->refer_call == p) { ast_log(LOG_NOTICE, "INVITE with replaces into it's own call id (%s == %s)!\n", replace_id, p->callid); - p->refer->refer_call = dialog_unref(p->refer->refer_call, "unref dialog p->refer->refer_call"); transmit_response_reliable(p, "400 Bad request", req); /* The best way to not not accept the transfer */ error = 1; } @@ -23142,6 +23146,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int if (p->refer->refer_call->owner) { ast_channel_unlock(p->refer->refer_call->owner); } + p->refer->refer_call = dialog_unref(p->refer->refer_call, "unref dialog p->refer->refer_call"); } refer_locked = 0; p->invitestate = INV_COMPLETED;