diff options
author | zuul <zuul@gerrit.asterisk.org> | 2016-02-11 16:45:59 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-02-11 16:45:59 -0600 |
commit | 8c15f309c2c4c9979727366f4d1263f5bddf5aa0 (patch) | |
tree | 6e21640540796e148bd95bc9b52009bb7dfaf672 /res | |
parent | 962a9d61f8666607b25fd3307cd938576ee60da0 (diff) | |
parent | 20e9792fbc7eb8c5ca23936bac7793e2f9be37c3 (diff) |
Merge "Resources/res_phoneprov: fix memory leak and heap-use-after-free" into 13
Diffstat (limited to 'res')
-rw-r--r-- | res/res_phoneprov.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c index b3d14f7b9..df93c5bbc 100644 --- a/res/res_phoneprov.c +++ b/res/res_phoneprov.c @@ -1193,8 +1193,7 @@ static struct ast_http_uri phoneprovuri = { static struct varshead *get_defaults(void) { - struct ast_config *phoneprov_cfg; - struct ast_config *cfg; + struct ast_config *phoneprov_cfg, *cfg = CONFIG_STATUS_FILEINVALID; const char *value; struct ast_variable *v; struct ast_var_t *var; @@ -1233,10 +1232,12 @@ static struct varshead *get_defaults(void) if (!value) { if ((cfg = ast_config_load("sip.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) { value = ast_variable_retrieve(cfg, "general", "bindport"); - ast_config_destroy(cfg); } } var = ast_var_assign(variable_lookup[AST_PHONEPROV_STD_SERVER_PORT], S_OR(value, "5060")); + if(cfg && cfg != CONFIG_STATUS_FILEINVALID) { + ast_config_destroy(cfg); + } AST_VAR_LIST_INSERT_TAIL(defaults, var); value = ast_variable_retrieve(phoneprov_cfg, "general", pp_general_lookup[AST_PHONEPROV_STD_PROFILE]); @@ -1288,6 +1289,7 @@ static int load_users(void) if (!(cfg = ast_config_load("users.conf", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "Unable to load users.conf\n"); + ast_var_list_destroy(defaults); return -1; } @@ -1337,6 +1339,7 @@ static int load_users(void) } } ast_config_destroy(cfg); + ast_var_list_destroy(defaults); return 0; } |