summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Grenville <pyxlcy@gmail.com>2015-09-22 08:34:28 +0800
committerRichard Grenville <pyxlcy@gmail.com>2015-09-22 08:34:28 +0800
commit2343e4bbd298b35ea5c190c52abd2b0cb9f79a18 (patch)
tree8f5d27be6680822a235209ab6f425a7177e6cf04
parentd7f95b56b176281bfb252c54defef48c9cd1f4e1 (diff)
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.
-rw-r--r--src/compton.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/compton.c b/src/compton.c
index 92d08dc..92935a3 100644
--- a/src/compton.c
+++ b/src/compton.c
@@ -5466,12 +5466,17 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
}
#endif
- if (CONFIG_FALSE == config_read(&cfg, f)) {
- 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;
+ {
+ 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);