From e2b99fc921a69824d03e9b690b43940b187e09b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 10 Feb 2026 15:46:05 +0100 Subject: [PATCH] Add a safety check in DetectZipFileContents --- Core/FileLoaders/ZipFileLoader.cpp | 1 + Core/Loaders.cpp | 6 ++++++ UI/InstallZipScreen.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/Core/FileLoaders/ZipFileLoader.cpp b/Core/FileLoaders/ZipFileLoader.cpp index c492f29eef..bc21e6cd8b 100644 --- a/Core/FileLoaders/ZipFileLoader.cpp +++ b/Core/FileLoaders/ZipFileLoader.cpp @@ -27,6 +27,7 @@ ZipFileLoader::ZipFileLoader(FileLoader *sourceLoader) if (!zipArchive_) { ERROR_LOG(Log::IO, "Failed to open ZIP archive: %s", zip_error_strerror(&error)); zip_source_free(zipSource); + // zipArchive_ is already nullptr here. } } diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index e116b1aab9..43c70acf4f 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -451,6 +451,12 @@ static bool ZipExtractFileToMemory(struct zip *z, int fileIndex, std::string *da void DetectZipFileContents(zip_t *z, ZipFileInfo *info) { int numFiles = zip_get_num_files(z); + if (numFiles < 0) { + // Broken zip archive? + ERROR_LOG(Log::HLE, "Failed to get the file count of zip file"); + info->contents = ZipFileContents::UNKNOWN; + return; + } _dbg_assert_(numFiles >= 0); // Verify that this is a PSP zip file with the correct layout. We also try diff --git a/UI/InstallZipScreen.cpp b/UI/InstallZipScreen.cpp index e8a7d80259..f33addfecf 100644 --- a/UI/InstallZipScreen.cpp +++ b/UI/InstallZipScreen.cpp @@ -238,6 +238,8 @@ void InstallZipScreen::CreateContentViews(UI::ViewGroup *parent) { break; } case ZipFileContents::FRAME_DUMP: + // Re-use an almost correct string, not worth it to add a new one + leftColumn->Add(new TextView(di->T("GE Frame Dumps"))); leftColumn->Add(new TextView(zipFileInfo_.contentName)); // It's a frame dump, add a play button! break;