diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-11-30 18:17:54 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-11-30 18:17:54 +0000 |
commit | d166b50ef315867514bda935eb1797793da556dd (patch) | |
tree | 100b95968854ab7ee21878e3a8d598fa248a9d46 /res | |
parent | 0916c53ea0a9fbb7d4e4a6091f6d175e9b9a7514 (diff) |
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)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@48146 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r-- | res/res_features.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/res/res_features.c b/res/res_features.c index a33844b1e..88e444695 100644 --- a/res/res_features.c +++ b/res/res_features.c @@ -2058,7 +2058,8 @@ static int load_config(void) 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 @@ static int load_config(void) 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 @@ static int load_config(void) } 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 @@ static int load_config(void) 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 @@ static int load_config(void) 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 @@ static int load_config(void) 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; } |