Fix crash if zip file cannot be opened (#14636)

Helped-by: savilli <78875209+savilli@users.noreply.github.com>
This commit is contained in:
grorp 2024-05-12 11:46:39 +02:00 committed by GitHub
parent a8af0c0ca4
commit 57b6e74abb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

@ -71,7 +71,9 @@ local function download_and_extract(param)
os.remove(filename)
if tempfolder == "" then
return {
msg = fgettext_ne("Failed to extract \"$1\" (unsupported file type or broken archive)", package.title),
msg = fgettext_ne("Failed to extract \"$1\" " ..
"(insufficient disk space, unsupported file type or broken archive)",
package.title),
}
end

@ -932,6 +932,8 @@ bool extractZipFile(io::IFileSystem *fs, const char *filename, const std::string
}
irr_ptr<io::IFileArchive> opened_zip(zip_loader->createArchive(filename, false, false));
if (!opened_zip)
return false;
const io::IFileList* files_in_zip = opened_zip->getFileList();
for (u32 i = 0; i < files_in_zip->getFileCount(); i++) {