mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Add a safety check in DetectZipFileContents
This commit is contained in:
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user