[Asterisk-cvs] asterisk config.c,1.67,1.68

kpfleming at lists.digium.com kpfleming at lists.digium.com
Tue Jun 7 17:25:44 CDT 2005


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

Modified Files:
	config.c 
Log Message:
fix memory leaks in config loader (bug #4223)


Index: config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/config.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- config.c	6 Jun 2005 22:12:18 -0000	1.67
+++ config.c	7 Jun 2005 21:28:04 -0000	1.68
@@ -499,7 +499,7 @@
 				if(!ast_strlen_zero(exec_file))
 					unlink(exec_file);
 				if(!do_include)
-					return -1;
+					return 0;
 
 			} else {
 				ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n", 
@@ -556,6 +556,7 @@
 	int lineno=0;
 	int comment = 0, nest[MAX_NESTED_COMMENTS];
 	struct ast_category *cat = NULL;
+	int count = 0;
 	
 	cat = ast_config_get_current_category(cfg);
 
@@ -592,6 +593,7 @@
 		fflush(stdout);
 	}
 	if ((f = fopen(fn, "r"))) {
+		count++;
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Parsing %s\n", fn);
 		else if (option_verbose > 1)
@@ -674,6 +676,8 @@
 			}
 		}
 #endif
+	if (count == 0)
+		return NULL;
 
 	return cfg;
 }
@@ -793,17 +797,19 @@
 
 void read_config_maps(void) 
 {
-	struct ast_config *config;
+	struct ast_config *config, *configtmp;
 	struct ast_variable *v;
 	char *driver, *table, *database, *stringp;
 
 	clear_config_maps();
 
-	config = ast_config_new();
-	config->max_include_level = 1;
-	config = ast_config_internal_load(extconfig_conf, config);
-	if (!config)
+	configtmp = ast_config_new();
+	configtmp->max_include_level = 1;
+	config = ast_config_internal_load(extconfig_conf, configtmp);
+	if (!config) {
+		ast_config_destroy(configtmp);
 		return;
+	}
 
 	for (v = ast_variable_browse(config, "settings"); v; v = v->next) {
 		stringp = v->value;




More information about the svn-commits mailing list