From: Mark Michelson Date: Thu, 13 Jun 2013 18:17:13 +0000 (+0000) Subject: Fix memory leak in features_config.c X-Git-Tag: 13.0.0-beta1~1673 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49949ac5a90d29ef23dc7fe46d802f1c08546352;p=thirdparty%2Fasterisk.git 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 --- diff --git a/main/features_config.c b/main/features_config.c index 163c37dfa3..6d5cf1a5e7 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));