[asterisk-commits] mmichelson: trunk r263810 - /trunk/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 18 15:09:26 CDT 2010


Author: mmichelson
Date: Tue May 18 15:09:24 2010
New Revision: 263810

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=263810
Log:
Fix memory leaks in redirecting structures in chan_sip.c

Thanks to Richard for pointing this out.


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=263810&r1=263809&r2=263810
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue May 18 15:09:24 2010
@@ -17535,7 +17535,12 @@
 		ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name);
 		redirecting->from.name = redirecting_from_name;
 	}
-	redirecting->from.tag = (char *) p->cid_tag;
+	if (!ast_strlen_zero(p->cid_tag)) {
+		if (redirecting->from.tag) {
+			ast_free(redirecting->from.tag);
+		}
+		redirecting->from.tag = ast_strdup(p->cid_tag);
+	}
 	if (!ast_strlen_zero(redirecting_to_number)) {
 		if (redirecting->to.number) {
 			ast_free(redirecting->to.number);
@@ -17929,6 +17934,7 @@
 			struct ast_party_redirecting redirecting = {{0,},};
 			change_redirecting_information(p, req, &redirecting, FALSE);
 			ast_channel_queue_redirecting_update(p->owner, &redirecting);
+			ast_party_redirecting_free(&redirecting);
 			sip_handle_cc(p, req, AST_CC_CCNR);
 		}
 		check_pendings(p);
@@ -18902,6 +18908,7 @@
 					struct ast_party_redirecting redirecting = {{0,},};
 					change_redirecting_information(p, req, &redirecting, TRUE);
 					ast_channel_set_redirecting(p->owner, &redirecting);
+					ast_party_redirecting_free(&redirecting);
 				}
 					/* Fall through */
 				case 486: /* Busy here */
@@ -20490,7 +20497,6 @@
 	if (!p->lastinvite && !req->ignore && !p->owner) {
 		/* This is a new invite */
 		/* Handle authentication if this is our first invite */
-		struct ast_party_redirecting redirecting = {{0,},};
 		int cc_recall_core_id = -1;
 		set_pvt_allowed_methods(p, req);
 		res = check_user(p, req, SIP_INVITE, e, XMIT_RELIABLE, sin);
@@ -20560,7 +20566,6 @@
 			goto request_invite_cleanup;
 		}
 		gotdest = get_destination(p, NULL, &cc_recall_core_id);	/* Get destination right away */
-		change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
 		extract_uri(p, req);			/* Get the Contact URI */
 		build_contact(p);			/* Build our contact header */
 
@@ -20607,9 +20612,12 @@
 			build_route(p, req, 0);
 
 			if (c) {
+				struct ast_party_redirecting redirecting = { { 0, }, };
 				/* Pre-lock the call */
 				ast_channel_lock(c);
+				change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
 				ast_channel_set_redirecting(c, &redirecting);
+				ast_party_redirecting_free(&redirecting);
 			}
 		}
 	} else {
@@ -20627,6 +20635,7 @@
 		if (c) {
 			ast_channel_set_redirecting(c, &redirecting);
 		}
+		ast_party_redirecting_free(&redirecting);
 	}
 
 	/* Session-Timers */




More information about the asterisk-commits mailing list