Add a safety check in DetectZipFileContents

This commit is contained in:
Henrik Rydgård
2026-02-10 15:46:05 +01:00
parent b43a86a9f3
commit e2b99fc921
3 changed files with 9 additions and 0 deletions
+1
View File
@@ -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.
}
}
+6
View File
@@ -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
+2
View File
@@ -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;