From 38c69f1814d862a9a78a5207737d287d7673b2b5 Mon Sep 17 00:00:00 2001 From: "Mateo \"Kuruk\" Miccino" Date: Sun, 23 Feb 2025 10:25:34 -0300 Subject: [PATCH] Fix file handle leak in ZipArchive and FileAccessZip --- core/io/file_access_zip.cpp | 7 ++----- core/io/file_access_zip.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index 16c0bcd28d6..33bceee52d9 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -174,7 +174,6 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6 Package pkg; pkg.filename = p_path; - pkg.zfile = zfile; packages.push_back(pkg); int pkg_num = packages.size() - 1; @@ -201,6 +200,8 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6 } } + unzClose(zfile); + return true; } @@ -225,10 +226,6 @@ ZipArchive::ZipArchive() { } ZipArchive::~ZipArchive() { - for (int i = 0; i < packages.size(); i++) { - unzClose(packages[i].zfile); - } - packages.clear(); } diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index 1713bced017..80ddeb52bf9 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -47,7 +47,6 @@ public: private: struct Package { String filename; - unzFile zfile = nullptr; }; Vector packages;