diff --git a/src/passbook.c b/src/passbook.c
index 0d5c7bf93a36adcfa1c1eda51e3ecda5287261ce..9f58f152e07f184181b7a86e2c2bef996ec724eb 100644
--- a/src/passbook.c
+++ b/src/passbook.c
@@ -512,11 +512,9 @@ static int run(FILE *f){
if (res == NULL){
if (feof(f)){
/* end of file */
- fclose(f);
return instructionCount;
}else{
debug_printf("Error while reading, having read %d lines\n",instructionCount);
- fclose(f);
return -1;
}
}
@@ -524,7 +522,6 @@ static int run(FILE *f){
if (!(inst[MAX_LINE_LENGTH] == '\n' && inst[MAX_LINE_LENGTH+1] == '\0')){
fprintf(stderr,"Line %d exceeds maximum length (%d)\n",instructionCount+1,MAX_LINE_LENGTH);
debug_printf("(Expected at array index %d to find NUL but found '%c' (%d))\n",MAX_LINE_LENGTH,inst[MAX_LINE_LENGTH],inst[MAX_LINE_LENGTH]);
- fclose(f);
return -1;
}
}else{
@@ -548,7 +545,6 @@ static int run(FILE *f){
if (feof(f)){
/* final line of file didn't have a trailing newline */
- fclose(f);
return instructionCount;
}else{
/* see if we are at end of file by trying to do one more read.
@@ -558,17 +554,14 @@ static int run(FILE *f){
int res = fread(&c,1,1,f);
if (res == 1){
fprintf(stderr,"Number of instructions (lines) in file exceeds max (%d)\n",MAX_INSTRUCTIONS);
- fclose(f);
return -1;
}else{
if (feof(f)){
/* final read found the EOF, so all good */
- fclose(f);
return instructionCount;
}else{
/* probably won't ever get here */
debug_printf("Error while trying to test if line %d was empty\n",instructionCount+1);
- fclose(f);
return -1;
}
}