From 9bb255bc7c577df18ae27122936affe1155ab4cd Mon Sep 17 00:00:00 2001
From: Walter Doekes <walter+asterisk@wjd.nu>
Date: Wed, 24 Sep 2014 08:49:20 +0000
Subject: [PATCH] chan_sip: Unref outbound proxy structure on dialog/pvt
 destruction.

Make sure outbound proxy refs are always unreffed on dialog destruction.

Review: https://reviewboard.asterisk.org/r/4016/
........

Merged revisions 423800 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@423801 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_sip.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 39250923a4..668eeec297 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -4363,7 +4363,7 @@ int __sip_ack(struct sip_pvt *p, uint32_t seqno, int resp, int sipmethod)
 	  If obforcing is set, we will keep the outbound proxy during the whole
 	  dialog, regardless of what the SIP rfc says
 	*/
-	if (p->outboundproxy && !p->outboundproxy->force){
+	if (p->outboundproxy && !p->outboundproxy->force) {
 		ref_proxy(p, NULL);
 	}
 
@@ -6383,6 +6383,10 @@ void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
 		p->options = NULL;
 	}
 
+	if (p->outboundproxy) {
+		ref_proxy(p, NULL);
+	}
+
 	if (p->notify) {
 		ast_variables_destroy(p->notify->headers);
 		ast_free(p->notify->content);
-- 
GitLab