From c328fc6fe458ec4f375519abdcc4eb7865c66fdf Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 30 Jan 2023 19:26:49 +0200 Subject: [PATCH] seems that we can't MapViewOfFile big images , return an error in failure --- shadPS4/emulator/fileFormat/PKG.cpp | 5 +++++ shadPS4/emulator/fileFormat/PKG.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/shadPS4/emulator/fileFormat/PKG.cpp b/shadPS4/emulator/fileFormat/PKG.cpp index b859056e..e8a88b8e 100644 --- a/shadPS4/emulator/fileFormat/PKG.cpp +++ b/shadPS4/emulator/fileFormat/PKG.cpp @@ -54,6 +54,11 @@ bool PKG::extract(const std::string& filepath, const std::string& extractPath, s } file.Seek(0, fsSeekSet); pkg = (U08*)mmap(pkgSize, file.fileDescr()); + if (pkg == nullptr) + { + failreason = "Can't allocate size for image"; + return false; + } file.Read(pkg, pkgSize); diff --git a/shadPS4/emulator/fileFormat/PKG.h b/shadPS4/emulator/fileFormat/PKG.h index 8685bee0..74c4bb6f 100644 --- a/shadPS4/emulator/fileFormat/PKG.h +++ b/shadPS4/emulator/fileFormat/PKG.h @@ -135,6 +135,10 @@ public: if (hHandle != NULL) { pStart = MapViewOfFile(hHandle, FILE_MAP_COPY, 0, 0, sLength); } + if(pStart == NULL) + { + return nullptr; + } return pStart; } int munmap(void* pStart) {