summaryrefslogtreecommitdiff
path: root/main/features_config.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2013-06-13 18:17:13 +0000
committerMark Michelson <mmichelson@digium.com>2013-06-13 18:17:13 +0000
commit49949ac5a90d29ef23dc7fe46d802f1c08546352 (patch)
tree92955a28cded12e6bac3708bea0bdee1f360ba21 /main/features_config.c
parent1cb25deeba899dc1e4a2c51ba5934cc258b5c91f (diff)
Fix memory leak in features_config.c
The options should not be registered multiple times. Instead, the configuration just needs to be reprocessed by the config framework. This also exposed that we were not properly telling the config framework to treat the configuration processing with the "reload" semantics when a reload occurred. Both of these errors are fixed now. Thanks to Richard Mudgett for discovering the leak. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391676 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/features_config.c')
-rw-r--r--main/features_config.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/main/features_config.c b/main/features_config.c
index 163c37dfa..6d5cf1a5e 100644
--- a/main/features_config.c
+++ b/main/features_config.c
@@ -1345,9 +1345,9 @@ static struct ast_custom_function featuremap_function = {
.write = featuremap_write
};
-static int load_config(int reload)
+static int load_config(void)
{
- if (!reload && aco_info_init(&cfg_info)) {
+ if (aco_info_init(&cfg_info)) {
ast_log(LOG_ERROR, "Unable to initialize configuration info for features\n");
return -1;
}
@@ -1441,10 +1441,8 @@ static int load_config(int reload)
if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
ast_log(LOG_ERROR, "Failed to process features.conf configuration!\n");
- if (!reload) {
- aco_info_destroy(&cfg_info);
- ao2_global_obj_release(globals);
- }
+ aco_info_destroy(&cfg_info);
+ ao2_global_obj_release(globals);
return -1;
}
@@ -1559,14 +1557,17 @@ void ast_features_config_shutdown(void)
int ast_features_config_reload(void)
{
- return load_config(1);
+ if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) {
+ return -1;
+ }
+ return load_config();
}
int ast_features_config_init(void)
{
int res;
- res = load_config(0);
+ res = load_config();
res |= __ast_custom_function_register(&feature_function, NULL);
res |= __ast_custom_function_register(&featuremap_function, NULL);
res |= ast_cli_register_multiple(cli_features_config, ARRAY_LEN(cli_features_config));