From 270807c3d3001682d4c21618c32ee3c8aff70b13 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:51:17 +0200 Subject: [PATCH] Test fpOutCD, like fpOut and fpZip Close any open files upon error. --- contrib/minizip/mztools.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c index f86c1e71b..2cdc638d2 100644 --- a/contrib/minizip/mztools.c +++ b/contrib/minizip/mztools.c @@ -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]; @@ -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;