From 2dad2fbce2db76d27dc2504c34aedf302ef0a74f Mon Sep 17 00:00:00 2001 From: aaronp64 Date: Mon, 8 Apr 2024 15:57:35 -0400 Subject: [PATCH] Fix ZIPReader.get_files() error on empty zip files Added check for empty zip file before trying to look at first file Fixes #90388 --- modules/zip/zip_reader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/zip/zip_reader.cpp b/modules/zip/zip_reader.cpp index f4a92dce5b9..123d1e5d468 100644 --- a/modules/zip/zip_reader.cpp +++ b/modules/zip/zip_reader.cpp @@ -58,7 +58,14 @@ Error ZIPReader::close() { PackedStringArray ZIPReader::get_files() { ERR_FAIL_COND_V_MSG(fa.is_null(), PackedStringArray(), "ZIPReader must be opened before use."); - int err = unzGoToFirstFile(uzf); + unz_global_info gi; + int err = unzGetGlobalInfo(uzf, &gi); + ERR_FAIL_COND_V(err != UNZ_OK, PackedStringArray()); + if (gi.number_entry == 0) { + return PackedStringArray(); + } + + err = unzGoToFirstFile(uzf); ERR_FAIL_COND_V(err != UNZ_OK, PackedStringArray()); List s;