[svn-commits] file: branch 1.2 r53357 - /branches/1.2/channels/chan_iax2.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Feb 7 08:38:49 MST 2007


Author: file
Date: Wed Feb  7 09:38:48 2007
New Revision: 53357

URL: http://svn.digium.com/view/asterisk?view=rev&rev=53357
Log:
Fix a few potential memory leaks with realtime users and peers. (issue #8999 reported by bsmithurst)

Modified:
    branches/1.2/channels/chan_iax2.c

Modified: branches/1.2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_iax2.c?view=diff&rev=53357&r1=53356&r2=53357
==============================================================================
--- branches/1.2/channels/chan_iax2.c (original)
+++ branches/1.2/channels/chan_iax2.c Wed Feb  7 09:38:48 2007
@@ -2634,8 +2634,10 @@
 
 	peer = build_peer(peername, var, ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS) ? 0 : 1);
 	
-	if (!peer)
+	if (!peer) {
+		ast_variables_destroy(var);
 		return NULL;
+	}
 
 	tmp = var;
 	while(tmp) {
@@ -2661,10 +2663,11 @@
 		}
 		tmp = tmp->next;
 	}
+
+	ast_variables_destroy(var);
+
 	if (!peer)
 		return NULL;
-
-	ast_variables_destroy(var);
 
 	if (ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS)) {
 		ast_copy_flags(peer, &globalflags, IAX_RTAUTOCLEAR|IAX_RTCACHEFRIENDS);
@@ -2725,10 +2728,11 @@
 	}
 
 	user = build_user(username, var, !ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS));
+
+	ast_variables_destroy(var);
+
 	if (!user)
 		return NULL;
-
-	ast_variables_destroy(var);
 
 	if (ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS)) {
 		ast_set_flag(user, IAX_RTCACHEFRIENDS);
@@ -4925,15 +4929,12 @@
 					key++;
 				}
 			}
-			if (!family || !key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret))) {
+			if (!family || !key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret)))
 				ast_log(LOG_WARNING, "Unable to retrieve database password for family/key '%s'!\n", user->dbsecret);
-				if (ast_test_flag(user, IAX_TEMPONLY)) {
-					destroy_user(user);
-					user = NULL;
-				}
-			}
 		} else
 			ast_copy_string(iaxs[callno]->secret, user->secret, sizeof(iaxs[callno]->secret)); 
+		if (ast_test_flag(user, IAX_TEMPONLY))
+			destroy_user(user);
 		res = 0;
 	}
 	ast_set2_flag(iaxs[callno], iax2_getpeertrunk(*sin), IAX_TRUNK);	



More information about the svn-commits mailing list