diff options
| author | Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> | 2024-06-09 10:51:17 +0200 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2026-02-11 15:40:53 -0800 |
| commit | af0aa9b66a2d123a1ca26d9bfe138695012b045b (patch) | |
| tree | a380121b9b5a58942e14c3b47f4936036cba212d | |
| parent | 43386cf1dda163e1cad18cae0d7e956056c62f0b (diff) | |
| download | zlib-af0aa9b66a2d123a1ca26d9bfe138695012b045b.tar.gz zlib-af0aa9b66a2d123a1ca26d9bfe138695012b045b.tar.bz2 zlib-af0aa9b66a2d123a1ca26d9bfe138695012b045b.zip | |
Catch a file open error in contrib/minizip/mztools.c.
And close those successfully opened.
| -rw-r--r-- | contrib/minizip/mztools.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c index 6260cb0e..1e2bb568 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* | |||
| 35 | FILE* fpZip = fopen(file, "rb"); | 35 | FILE* fpZip = fopen(file, "rb"); |
| 36 | FILE* fpOut = fopen(fileOut, "wb"); | 36 | FILE* fpOut = fopen(fileOut, "wb"); |
| 37 | FILE* fpOutCD = fopen(fileOutTmp, "wb"); | 37 | FILE* fpOutCD = fopen(fileOutTmp, "wb"); |
| 38 | if (fpZip != NULL && fpOut != NULL) { | 38 | if (fpZip != NULL && fpOut != NULL && fpOutCD != NULL ) { |
| 39 | int entries = 0; | 39 | int entries = 0; |
| 40 | uLong totalBytes = 0; | 40 | uLong totalBytes = 0; |
| 41 | char header[30]; | 41 | char header[30]; |
| @@ -282,6 +282,12 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* | |||
| 282 | } | 282 | } |
| 283 | } | 283 | } |
| 284 | } else { | 284 | } else { |
| 285 | if (fpOutCD != NULL) | ||
| 286 | fclose(fpOutCD); | ||
| 287 | if (fpZip != NULL) | ||
| 288 | fclose(fpZip); | ||
| 289 | if (fpOut != NULL) | ||
| 290 | fclose(fpOut); | ||
| 285 | err = Z_STREAM_ERROR; | 291 | err = Z_STREAM_ERROR; |
| 286 | } | 292 | } |
| 287 | return err; | 293 | return err; |
