Skip to content

Commit 29806a1

Browse files
committed
Low: read_config: close config file when no longer needed
Discovered-by: static analysis/Coverity
1 parent f436cba commit 29806a1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/config.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ int read_config(const char *path, int type)
486486
booth_conf = malloc(sizeof(struct booth_config)
487487
+ TICKET_ALLOC * sizeof(struct ticket_config));
488488
if (!booth_conf) {
489+
fclose(fp);
489490
log_error("failed to alloc memory for booth config");
490491
return -ENOMEM;
491492
}
@@ -788,6 +789,7 @@ int read_config(const char *path, int type)
788789
error = "Unknown keyword";
789790
goto err;
790791
}
792+
fclose(fp);
791793

792794
if ((booth_conf->site_count % 2) == 0) {
793795
log_warn("Odd number of nodes is strongly recommended!");
@@ -820,6 +822,7 @@ int read_config(const char *path, int type)
820822

821823

822824
err:
825+
fclose(fp);
823826
out:
824827
log_error("%s in config file line %d",
825828
error, lineno);

0 commit comments

Comments
 (0)