[asterisk-commits] russell: branch 1.4 r79436 - /branches/1.4/channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 14 12:31:39 CDT 2007


Author: russell
Date: Tue Aug 14 12:31:39 2007
New Revision: 79436

URL: http://svn.digium.com/view/asterisk?view=rev&rev=79436
Log:
Fix some memory leaks throughout chan_iax2 related to the use of realtime.
I found these while working on iax2_peer object reference tracking.

Modified:
    branches/1.4/channels/chan_iax2.c

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=79436&r1=79435&r2=79436
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Tue Aug 14 12:31:39 2007
@@ -5701,8 +5701,11 @@
 		return -1;
 	}
 	ast_mutex_lock(&iaxsl[callno]);
-	if (!iaxs[callno])
+	if (!iaxs[callno]) {
+		if (ast_test_flag(p, IAX_TEMPONLY))
+			destroy_peer(p);
 		return -1;
+	}
 
 	if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS))) {
 		if (sin->sin_addr.s_addr) {
@@ -5742,8 +5745,11 @@
 	}		
 
 	/* Make sure our call still exists, an INVAL at the right point may make it go away */
-	if (!iaxs[callno])
+	if (!iaxs[callno]) {
+		if (ast_test_flag(p, IAX_TEMPONLY))
+			destroy_peer(p);
 		return 0;
+	}
 
 	/* Store socket fd */
 	p->sockfd = fd;
@@ -5807,8 +5813,11 @@
 	ast_mutex_unlock(&iaxsl[callno]);
 	p = find_peer(peer_name, 1);
 	ast_mutex_lock(&iaxsl[callno]);
-	if (!iaxs[callno])
+	if (!iaxs[callno]) {
+		if (p && ast_test_flag(p, IAX_TEMPONLY))
+			destroy_peer(p);
 		return -1;
+	}
 	if (p) {
 		memset(&ied, 0, sizeof(ied));
 		iax_ie_append_short(&ied, IAX_IE_AUTHMETHODS, p->authmethods);
@@ -10020,6 +10029,9 @@
 		}
 	}
 
+	if (ast_test_flag(peer, IAX_TEMPONLY))
+		destroy_peer(peer);
+
 	return 0;
 }
 




More information about the asterisk-commits mailing list