[Asterisk-cvs] asterisk/channels chan_iax2.c,1.93,1.94

markster at lists.digium.com markster at lists.digium.com
Tue Feb 10 21:45:42 CST 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv17917/channels

Modified Files:
	chan_iax2.c 
Log Message:
Fix several memory leaks


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- chan_iax2.c	11 Feb 2004 00:17:48 -0000	1.93
+++ chan_iax2.c	11 Feb 2004 03:54:28 -0000	1.94
@@ -5210,6 +5210,7 @@
 {
 	struct iax2_peer *peer;
 	struct iax2_peer *prev;
+	struct ast_ha *oldha = NULL;
 	int maskfound=0;
 	int format;
 	int found=0;
@@ -5225,6 +5226,8 @@
 	}
 	if (peer) {
 		found++;
+		oldha = peer->ha;
+		peer->ha = NULL;
 		/* Already in the list, remove it and it will be added back (or FREE'd) */
 		if (prev) {
 			prev->next = peer->next;
@@ -5351,6 +5354,8 @@
 		if (!found && peer->dynamic)
 			reg_source_db(peer);
 	}
+	if (oldha)
+		ast_free_ha(oldha);
 	return peer;
 }
 
@@ -5358,6 +5363,8 @@
 {
 	struct iax2_user *prev, *user;
 	struct iax2_context *con, *conl = NULL;
+	struct ast_ha *oldha = NULL;
+	struct iax2_context *oldcon = NULL;
 	int format;
 	int found;
 	
@@ -5373,6 +5380,10 @@
 	}
 	if (user) {
 		found++;
+		oldha = user->ha;
+		oldcon = user->contexts;
+		user->ha = NULL;
+		user->contexts = NULL;
 		/* Already in the list, remove it and it will be added back (or FREE'd) */
 		if (prev) {
 			prev->next = user->next;
@@ -5458,6 +5469,10 @@
 		}
 		user->delme = 0;
 	}
+	if (oldha)
+		ast_free_ha(oldha);
+	if (oldcon)
+		free_context(oldcon);
 	return user;
 }
 
@@ -5520,6 +5535,7 @@
 	for (peer=peerl.peers;peer;) {
 		peernext = peer->next;
 		if (peer->delme) {
+			ast_free_ha(peer->ha);
 			for (x=0;x<IAX_MAX_CALLS;x++) {
 				ast_mutex_lock(&iaxsl[x]);
 				if (iaxs[x] && (iaxs[x]->peerpoke == peer)) {




More information about the svn-commits mailing list