Skip to content

Commit 7655bda

Browse files
Test fpOutCD, like fpOut and fpZip
Close any open files upon error.
1 parent 5a82f71 commit 7655bda

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contrib/minizip/mztools.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
3535
FILE* fpZip = fopen(file, "rb");
3636
FILE* fpOut = fopen(fileOut, "wb");
3737
FILE* fpOutCD = fopen(fileOutTmp, "wb");
38-
if (fpZip != NULL && fpOut != NULL) {
38+
if (fpZip != NULL && fpOut != NULL && fpOutCD != NULL ) {
3939
int entries = 0;
4040
uLong totalBytes = 0;
4141
char header[30];
@@ -282,6 +282,12 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
282282
}
283283
}
284284
} else {
285+
if (fpOutCD != NULL)
286+
fclose(fpOutCD);
287+
if (fpZip != NULL)
288+
fclose(fpZip);
289+
if (fpOut != NULL)
290+
fclose(fpOut);
285291
err = Z_STREAM_ERROR;
286292
}
287293
return err;

0 commit comments

Comments
 (0)