[asterisk-commits] file: branch 1.4 r53358 - in /branches/1.4: ./ channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Feb 7 08:43:39 MST 2007


Author: file
Date: Wed Feb  7 09:43:39 2007
New Revision: 53358

URL: http://svn.digium.com/view/asterisk?view=rev&rev=53358
Log:
Merged revisions 53357 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r53357 | file | 2007-02-07 10:38:48 -0500 (Wed, 07 Feb 2007) | 2 lines

Fix a few potential memory leaks with realtime users and peers. (issue #8999 reported by bsmithurst)

........

Modified:
    branches/1.4/   (props changed)
    branches/1.4/channels/chan_iax2.c

Propchange: branches/1.4/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

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=53358&r1=53357&r2=53358
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Wed Feb  7 09:43:39 2007
@@ -2446,8 +2446,10 @@
 
 	peer = build_peer(peername, var, NULL, ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS) ? 0 : 1);
 	
-	if (!peer)
+	if (!peer) {
+		ast_variables_destroy(var);
 		return NULL;
+	}
 
 	for (tmp = var; tmp; tmp = tmp->next) {
 		/* Make sure it's not a user only... */
@@ -2470,10 +2472,11 @@
 				dynamic = 1;
 		}
 	}
+
+	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);
@@ -2533,10 +2536,11 @@
 	}
 
 	user = build_user(username, var, NULL, !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);
@@ -4739,16 +4743,14 @@
 				*key = '\0';
 				key++;
 			}
-			if (!key || ast_db_get(family, key, buf, sizeof(buf))) {
+			if (!key || ast_db_get(family, key, buf, sizeof(buf)))
 				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
+			else
 				ast_string_field_set(iaxs[callno], secret, buf);
 		} else
 			ast_string_field_set(iaxs[callno], secret, user->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 asterisk-commits mailing list