diff --git a/fdrd.c b/fdrd.c index a899110..a836044 100644 --- a/fdrd.c +++ b/fdrd.c @@ -559,7 +559,7 @@ saveto(struct instance *insp, struct item *itp) int read_config_file(const char *fpath, const struct stat *sb, int typeflag) { - FILE *f; + FILE *f; char buf[BUFSIZE], save_buf[BUFSIZE], *bp; int l; struct item *itp; @@ -590,6 +590,7 @@ read_config_file(const char *fpath, const struct stat *sb, int typeflag) insp = malloc(sizeof(struct instance)); if (insp == NULL) { perror("malloc"); + fclose(f) return 1; } insque(insp, &anchor); @@ -637,6 +638,7 @@ read_config_file(const char *fpath, const struct stat *sb, int typeflag) itp = malloc(sizeof(struct item)); if (itp == NULL) { perror("malloc"); + fclose(f); exit(EC_MALLOC); } @@ -714,6 +716,7 @@ read_config_file(const char *fpath, const struct stat *sb, int typeflag) insp->ilast = itp; } } + fclose(f); return 0; }