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) {