From: Alan T. DeKok Date: Mon, 18 Feb 2013 19:01:32 +0000 (-0500) Subject: cf_section_parse_free() recurses into sub-sections X-Git-Tag: release_2_2_1~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a77268b32d944fd0fa21e4b023b46b512f80a0f;p=thirdparty%2Ffreeradius-server.git cf_section_parse_free() recurses into sub-sections --- diff --git a/src/main/conffile.c b/src/main/conffile.c index d57c53f7000..13fb3a40c54 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -300,10 +300,25 @@ void cf_section_parse_free(CONF_SECTION *cs, void *base) * Free up dynamically allocated string pointers. */ for (i = 0; variables[i].name != NULL; i++) { + int type; char **p; - if ((variables[i].type != PW_TYPE_STRING_PTR) && - (variables[i].type != PW_TYPE_FILENAME)) { + type = variables[i].type; + + if (type == PW_TYPE_SUBSECTION) { + CONF_SECTION *subcs; + subcs = cf_section_sub_find(cs, variables[i].name); + + if (!subcs) continue; + + if (!variables[i].dflt) continue; + + cf_section_parse_free(subcs, base); + continue; + } + + if ((type != PW_TYPE_STRING_PTR) && + (type != PW_TYPE_FILENAME)) { continue; } @@ -329,6 +344,8 @@ void cf_section_parse_free(CONF_SECTION *cs, void *base) free(*p); *p = NULL; } + + cs->variables = NULL; }