[asterisk-commits] mmichelson: branch 1.4 r165255 - /branches/1.4/apps/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 17 14:51:38 CST 2008


Author: mmichelson
Date: Wed Dec 17 14:51:38 2008
New Revision: 165255

URL: http://svn.digium.com/view/asterisk?view=rev&rev=165255
Log:
Fix some memory leaks found while looking at how realtime
configs are handled.

Also cleaned up some coding guidelines violations in app_realtime.c,
mostly related to spacing


Modified:
    branches/1.4/apps/app_directory.c
    branches/1.4/apps/app_meetme.c
    branches/1.4/apps/app_queue.c
    branches/1.4/apps/app_realtime.c

Modified: branches/1.4/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_directory.c?view=diff&rev=165255&r1=165254&r2=165255
==============================================================================
--- branches/1.4/apps/app_directory.c (original)
+++ branches/1.4/apps/app_directory.c Wed Dec 17 14:51:38 2008
@@ -389,6 +389,9 @@
 		if (!cat) {
 			ast_log(LOG_WARNING, "Out of memory\n");
 			ast_config_destroy(cfg);
+			if (rtdata) {
+				ast_config_destroy(rtdata);
+			}
 			return NULL;
 		}
 		ast_category_append(cfg, cat);

Modified: branches/1.4/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_meetme.c?view=diff&rev=165255&r1=165254&r2=165255
==============================================================================
--- branches/1.4/apps/app_meetme.c (original)
+++ branches/1.4/apps/app_meetme.c Wed Dec 17 14:51:38 2008
@@ -2477,7 +2477,7 @@
 static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char *confno, int make, int dynamic,
 						 char *dynamic_pin, size_t pin_buf_len, int refcount, struct ast_flags *confflags)
 {
-	struct ast_variable *var;
+	struct ast_variable *var, *save;
 	struct ast_conference *cnf;
 
 	/* Check first in the conference list */
@@ -2499,6 +2499,7 @@
 		if (!var)
 			return NULL;
 
+		save = var;
 		while (var) {
 			if (!strcasecmp(var->name, "pin")) {
 				pin = ast_strdupa(var->value);
@@ -2507,7 +2508,7 @@
 			}
 			var = var->next;
 		}
-		ast_variables_destroy(var);
+		ast_variables_destroy(save);
 		
 		cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount);
 	}

Modified: branches/1.4/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_queue.c?view=diff&rev=165255&r1=165254&r2=165255
==============================================================================
--- branches/1.4/apps/app_queue.c (original)
+++ branches/1.4/apps/app_queue.c Wed Dec 17 14:51:38 2008
@@ -1301,11 +1301,12 @@
 
 static int update_realtime_member_field(struct member *mem, const char *queue_name, const char *field, const char *value)
 {
-	struct ast_variable *var;
+	struct ast_variable *var, *save;
 	int ret = -1;
 
 	if (!(var = ast_load_realtime("queue_members", "interface", mem->interface, "queue_name", queue_name, NULL))) 
 		return ret;
+	save = var;
 	while (var) {
 		if (!strcmp(var->name, "uniqueid"))
 			break;
@@ -1315,6 +1316,7 @@
 		if ((ast_update_realtime("queue_members", "uniqueid", var->value, field, value, NULL)) > -1)
 			ret = 0;
 	}
+	ast_variables_destroy(save);
 	return ret;
 }
 

Modified: branches/1.4/apps/app_realtime.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_realtime.c?view=diff&rev=165255&r1=165254&r2=165255
==============================================================================
--- branches/1.4/apps/app_realtime.c (original)
+++ branches/1.4/apps/app_realtime.c Wed Dec 17 14:51:38 2008
@@ -72,22 +72,24 @@
 static int cli_realtime_load(int fd, int argc, char **argv) 
 {
 	char *header_format = "%30s  %-30s\n";
-	struct ast_variable *var=NULL;
-
-	if(argc<5) {
+	struct ast_variable *var = NULL, *save = NULL;
+
+	if (argc < 5) {
 		ast_cli(fd, "You must supply a family name, a column to match on, and a value to match to.\n");
 		return RESULT_FAILURE;
 	}
 
 	var = ast_load_realtime(argv[2], argv[3], argv[4], NULL);
 
-	if(var) {
+	if (var) {
+		save = var;
 		ast_cli(fd, header_format, "Column Name", "Column Value");
 		ast_cli(fd, header_format, "--------------------", "--------------------");
-		while(var) {
+		while (var) {
 			ast_cli(fd, header_format, var->name, var->value);
 			var = var->next;
 		}
+		ast_variables_destroy(save);
 	} else {
 		ast_cli(fd, "No rows found matching search criteria.\n");
 	}




More information about the asterisk-commits mailing list