Skip to content

Commit

Permalink
Test fpOutCD, like fpOut and fpZip
Browse files Browse the repository at this point in the history
Close any open files upon error.
  • Loading branch information
DimitriPapadopoulos committed Jun 9, 2024
1 parent 0f51fb4 commit 270807c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contrib/minizip/mztools.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
FILE* fpZip = fopen(file, "rb");
FILE* fpOut = fopen(fileOut, "wb");
FILE* fpOutCD = fopen(fileOutTmp, "wb");
if (fpZip != NULL && fpOut != NULL) {
if (fpZip != NULL && fpOut != NULL && fpOutCD != NULL ) {
int entries = 0;
uLong totalBytes = 0;
char header[30];
Expand Down Expand Up @@ -282,6 +282,12 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
}
}
} else {
if (fpOutCD != NULL)
fclose(fpOutCD);
if (fpZip != NULL)
fclose(fpZip);
if (fpOut != NULL)
fclose(fpOut);
err = Z_STREAM_ERROR;
}
return err;
Expand Down

0 comments on commit 270807c

Please sign in to comment.