[asterisk-commits] file: branch 1.2 r48146 - /branches/1.2/res/res_features.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 30 11:17:54 MST 2006


Author: file
Date: Thu Nov 30 12:17:54 2006
New Revision: 48146

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48146
Log:
Remember the pointer to the allocated block of memory so that we can free it and not cause a memory leak. (issue #8449 reported by arkadia)

Modified:
    branches/1.2/res/res_features.c

Modified: branches/1.2/res/res_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/res/res_features.c?view=diff&rev=48146&r1=48145&r2=48146
==============================================================================
--- branches/1.2/res/res_features.c (original)
+++ branches/1.2/res/res_features.c Thu Nov 30 12:17:54 2006
@@ -2058,7 +2058,8 @@
 		ast_unregister_features();
 		var = ast_variable_browse(cfg, "applicationmap");
 		while(var) {
-			char *tmp_val=strdup(var->value);
+			char *tmp_val_orig=strdup(var->value);
+			char *tmp_val = tmp_val_orig;
 			char *exten, *party=NULL, *app=NULL, *app_args=NULL; 
 
 			if (!tmp_val) { 
@@ -2075,7 +2076,7 @@
 
 			if (!(app && strlen(app)) || !(exten && strlen(exten)) || !(party && strlen(party)) || !(var->name && strlen(var->name))) {
 				ast_log(LOG_NOTICE, "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",app,exten,party,var->name);
-				free(tmp_val);
+				free(tmp_val_orig);
 				var = var->next;
 				continue;
 			}
@@ -2090,7 +2091,7 @@
 				}
 				if (!feature) {
 					ast_log(LOG_NOTICE, "Malloc failed at feature mapping\n");
-					free(tmp_val);
+					free(tmp_val_orig);
 					var = var->next;
 					continue;
 				}
@@ -2099,7 +2100,6 @@
 				ast_copy_string(feature->sname,var->name,FEATURE_SNAME_LEN);
 				ast_copy_string(feature->app,app,FEATURE_APP_LEN);
 				ast_copy_string(feature->exten, exten,FEATURE_EXTEN_LEN);
-				free(tmp_val);
 				
 				if (app_args) 
 					ast_copy_string(feature->app_args,app_args,FEATURE_APP_ARGS_LEN);
@@ -2114,6 +2114,7 @@
 					ast_set_flag(feature,AST_FEATURE_FLAG_CALLEE);
 				else {
 					ast_log(LOG_NOTICE, "Invalid party specification for feature '%s', must be caller, or callee\n", var->name);
+					free(tmp_val_orig);
 					var = var->next;
 					continue;
 				}
@@ -2121,6 +2122,7 @@
 				ast_register_feature(feature);
 				
 				if (option_verbose >=1) ast_verbose(VERBOSE_PREFIX_2 "Mapping Feature '%s' to app '%s' with code '%s'\n", var->name, app, exten);  
+				free(tmp_val_orig);
 			}
 			var = var->next;
 		}	 



More information about the asterisk-commits mailing list