From 30278a5511c7bba935127f18784c6a9a9230bd6a Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 11 Feb 2021 16:31:04 +0100 Subject: [PATCH] 7z: close the file in case of error and when reusing --- core/archive/7zArchive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/archive/7zArchive.cpp b/core/archive/7zArchive.cpp index cb7919679..4f8201b2d 100644 --- a/core/archive/7zArchive.cpp +++ b/core/archive/7zArchive.cpp @@ -31,6 +31,7 @@ bool SzArchive::Open(const char* path) { SzArEx_Init(&szarchive); + File_Close(&archiveStream.file); File_Construct(&archiveStream.file); #ifdef USE_WINDOWS_FILE nowide::wstackstring wpath; @@ -50,7 +51,10 @@ bool SzArchive::Open(const char* path) LookToRead2_CreateVTable(&lookStream, false); lookStream.buf = (Byte *)ISzAlloc_Alloc(&g_Alloc, kInputBufSize); if (lookStream.buf == NULL) + { + File_Close(&archiveStream.file); return false; + } lookStream.bufSize = kInputBufSize; lookStream.realStream = &archiveStream.vt; LookToRead2_Init(&lookStream);