Fix segfault when unable to find PFSCOffset in pfs_image

This commit is contained in:
Marius Alexandersen 2024-08-31 23:33:47 +02:00
parent 95d58b8b18
commit ba89552373

View file

@ -258,6 +258,12 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
// Retrieve PFSC from decrypted pfs_image.
pfsc_offset = GetPFSCOffset(pfs_decrypted);
if (pfsc_offset == (u32)-1)
{
failreason = "Could not retrieve PFSC from decrypted pfs_image";
return false;
}
std::memcpy(pfsc.data(), pfs_decrypted.data() + pfsc_offset, length - pfsc_offset);
PFSCHdr pfsChdr;