[Asterisk-code-review] Resources/res phoneprov: fix memory leak and heap-use-after-... (asterisk[13])
Badalian Vyacheslav
asteriskteam at digium.com
Tue Feb 9 22:55:43 CST 2016
Badalian Vyacheslav has uploaded a new change for review.
https://gerrit.asterisk.org/2231
Change subject: Resources/res_phoneprov: fix memory leak and heap-use-after-free
......................................................................
Resources/res_phoneprov: fix memory leak and heap-use-after-free
* heap-use-after-free happens when we free "cfg"
but then use "value" which refers to it
* A memory leak occurs because in some cases
it is not released "defaults"
ASTERISK-25721 #close
Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav
Change-Id: I3807d3f4726df6864430ec144cf6265d3f538469
---
M res/res_phoneprov.c
1 file changed, 7 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/31/2231/1
diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c
index b3d14f7..8f69547 100644
--- a/res/res_phoneprov.c
+++ b/res/res_phoneprov.c
@@ -1233,10 +1233,14 @@
if (!value) {
if ((cfg = ast_config_load("sip.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
value = ast_variable_retrieve(cfg, "general", "bindport");
+ var = ast_var_assign(variable_lookup[AST_PHONEPROV_STD_SERVER_PORT], S_OR(value, "5060"));
ast_config_destroy(cfg);
+ } else {
+ var = ast_var_assign(variable_lookup[AST_PHONEPROV_STD_SERVER_PORT], "5060");
}
+ } else {
+ var = ast_var_assign(variable_lookup[AST_PHONEPROV_STD_SERVER_PORT], S_OR(value, "5060"));
}
- var = ast_var_assign(variable_lookup[AST_PHONEPROV_STD_SERVER_PORT], S_OR(value, "5060"));
AST_VAR_LIST_INSERT_TAIL(defaults, var);
value = ast_variable_retrieve(phoneprov_cfg, "general", pp_general_lookup[AST_PHONEPROV_STD_PROFILE]);
@@ -1288,6 +1292,7 @@
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 +1342,7 @@
}
}
ast_config_destroy(cfg);
+ ast_var_list_destroy(defaults);
return 0;
}
--
To view, visit https://gerrit.asterisk.org/2231
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3807d3f4726df6864430ec144cf6265d3f538469
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Badalian Vyacheslav <v.badalyan at open-bs.ru>
More information about the asterisk-code-review
mailing list