Misc #308: Close config file after using it

Misc #308: Close the config file after using it, instead of leaving it
open forever. Thanks to SyedAmerGilani for the report.
This commit is contained in:
Richard Grenville 2015-09-22 08:34:28 +08:00
parent d7f95b56b1
commit 2343e4bbd2
1 changed files with 11 additions and 6 deletions

View File

@ -5466,13 +5466,18 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
}
#endif
if (CONFIG_FALSE == config_read(&cfg, f)) {
{
int read_result = config_read(&cfg, f);
fclose(f);
f = NULL;
if (CONFIG_FALSE == read_result) {
printf("Error when reading configuration file \"%s\", line %d: %s\n",
path, config_error_line(&cfg), config_error_text(&cfg));
config_destroy(&cfg);
free(path);
return;
}
}
config_set_auto_convert(&cfg, 1);
if (path != ps->o.config_file) {