summaryrefslogtreecommitdiffstats
path: root/modules/zip/zip_reader.cpp
diff options
context:
space:
mode:
authoraaronp64 <aaronp.code@gmail.com>2024-04-08 15:57:35 -0400
committeraaronp64 <aaronp.code@gmail.com>2024-04-08 15:57:35 -0400
commit2dad2fbce2db76d27dc2504c34aedf302ef0a74f (patch)
treee2d282a7b9cf624ace01a9c4e08196f54c61aa17 /modules/zip/zip_reader.cpp
parent0c6b5efab329b0e43348b2fd3a291dfae70e96aa (diff)
downloadredot-engine-2dad2fbce2db76d27dc2504c34aedf302ef0a74f.tar.gz
Fix ZIPReader.get_files() error on empty zip files
Added check for empty zip file before trying to look at first file Fixes #90388
Diffstat (limited to 'modules/zip/zip_reader.cpp')
-rw-r--r--modules/zip/zip_reader.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/zip/zip_reader.cpp b/modules/zip/zip_reader.cpp
index f4a92dce5b..123d1e5d46 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<String> s;