From: Wouter Wijngaards Date: Mon, 6 Jun 2016 14:57:24 +0000 (+0000) Subject: - free acl-tags, acltag-action and acltag-data config lists during X-Git-Tag: release-1.5.10~103 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2cc017981b3f9da76dee57c5a37c9f9c098be4a4;p=thirdparty%2Funbound.git - free acl-tags, acltag-action and acltag-data config lists during initialisation to free up memory for more entries. git-svn-id: file:///svn/unbound/trunk@3761 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/acl_list.c b/daemon/acl_list.c index a6b8ee0e1..4d40b092c 100644 --- a/daemon/acl_list.c +++ b/daemon/acl_list.c @@ -294,11 +294,18 @@ read_acl_list(struct acl_list* acl, struct config_file* cfg) static int read_acl_tags(struct acl_list* acl, struct config_file* cfg) { - struct config_strbytelist* p; - for(p = cfg->acl_tags; p; p = p->next) { + struct config_strbytelist* np, *p = cfg->acl_tags; + cfg->acl_tags = NULL; + while(p) { log_assert(p->str && p->str2); if(!acl_list_tags_cfg(acl, p->str, p->str2, p->str2len)) return 0; + /* free the items as we go to free up memory */ + np = p->next; + free(p->str); + free(p->str2); + free(p); + p = np; } return 1; } @@ -307,12 +314,23 @@ read_acl_tags(struct acl_list* acl, struct config_file* cfg) static int read_acl_tag_actions(struct acl_list* acl, struct config_file* cfg) { - struct config_str3list* p; - for(p = cfg->acl_tag_actions; p; p = p->next) { + struct config_str3list* p, *np; + p = cfg->acl_tag_actions; + cfg->acl_tag_actions = NULL; + while(p) { log_assert(p->str && p->str2 && p->str3); if(!acl_list_tag_action_cfg(acl, cfg, p->str, p->str2, - p->str3)) + p->str3)) { + config_deltrplstrlist(p); return 0; + } + /* free the items as we go to free up memory */ + np = p->next; + free(p->str); + free(p->str2); + free(p->str3); + free(p); + p = np; } return 1; } @@ -321,11 +339,22 @@ read_acl_tag_actions(struct acl_list* acl, struct config_file* cfg) static int read_acl_tag_datas(struct acl_list* acl, struct config_file* cfg) { - struct config_str3list* p; - for(p = cfg->acl_tag_datas; p; p = p->next) { + struct config_str3list* p, *np; + p = cfg->acl_tag_datas; + cfg->acl_tag_datas = NULL; + while(p) { log_assert(p->str && p->str2 && p->str3); - if(!acl_list_tag_data_cfg(acl, cfg, p->str, p->str2, p->str3)) + if(!acl_list_tag_data_cfg(acl, cfg, p->str, p->str2, p->str3)) { + config_deltrplstrlist(p); return 0; + } + /* free the items as we go to free up memory */ + np = p->next; + free(p->str); + free(p->str2); + free(p->str3); + free(p); + p = np; } return 1; } diff --git a/doc/Changelog b/doc/Changelog index 98d42f0e2..527995228 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -4,6 +4,8 @@ - local-zone-override config directive. - access-control-tag-action and access-control-tag-data config directives. + - free acl-tags, acltag-action and acltag-data config lists during + initialisation to free up memory for more entries. 3 June 2016: Wouter - Fix to not ignore return value of chown() in daemon startup.