Skip to content

Commit 2343e4b

Browse files
committed
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.
1 parent d7f95b5 commit 2343e4b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/compton.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -5466,12 +5466,17 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
54665466
}
54675467
#endif
54685468

5469-
if (CONFIG_FALSE == config_read(&cfg, f)) {
5470-
printf("Error when reading configuration file \"%s\", line %d: %s\n",
5471-
path, config_error_line(&cfg), config_error_text(&cfg));
5472-
config_destroy(&cfg);
5473-
free(path);
5474-
return;
5469+
{
5470+
int read_result = config_read(&cfg, f);
5471+
fclose(f);
5472+
f = NULL;
5473+
if (CONFIG_FALSE == read_result) {
5474+
printf("Error when reading configuration file \"%s\", line %d: %s\n",
5475+
path, config_error_line(&cfg), config_error_text(&cfg));
5476+
config_destroy(&cfg);
5477+
free(path);
5478+
return;
5479+
}
54755480
}
54765481
config_set_auto_convert(&cfg, 1);
54775482

0 commit comments

Comments
 (0)