Fix leak of file handle in load_config_file()
This commit is contained in:
parent
bf820013df
commit
09d11ace60
35
src/conf.c
35
src/conf.c
@ -387,23 +387,30 @@ static int config_parse (struct config_s *conf, FILE * f)
|
|||||||
static int load_config_file (const char *config_fname, struct config_s *conf)
|
static int load_config_file (const char *config_fname, struct config_s *conf)
|
||||||
{
|
{
|
||||||
FILE *config_file;
|
FILE *config_file;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
config_file = fopen (config_fname, "r");
|
do {
|
||||||
if (!config_file) {
|
config_file = fopen (config_fname, "r");
|
||||||
fprintf (stderr,
|
if (!config_file) {
|
||||||
"%s: Could not open config file \"%s\".\n",
|
fprintf (stderr,
|
||||||
PACKAGE, config_fname);
|
"%s: Could not open config file \"%s\".\n",
|
||||||
return -1;
|
PACKAGE, config_fname);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (config_compile () || config_parse (conf, config_file)) {
|
if (config_compile () || config_parse (conf, config_file)) {
|
||||||
fprintf (stderr, "Unable to parse config file. "
|
fprintf (stderr, "Unable to parse config file. "
|
||||||
"Not starting.\n");
|
"Not starting.\n");
|
||||||
return -1;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (config_file);
|
ret = 0;
|
||||||
return 0;
|
} while (0);
|
||||||
|
|
||||||
|
if (config_file)
|
||||||
|
fclose (config_file);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize_with_defaults (struct config_s *conf,
|
static void initialize_with_defaults (struct config_s *conf,
|
||||||
|
Loading…
Reference in New Issue
Block a user