seems that we can't MapViewOfFile big images , return an error in failure

This commit is contained in:
georgemoralis 2023-01-30 19:26:49 +02:00
parent e22e99a9db
commit c328fc6fe4
2 changed files with 9 additions and 0 deletions

View file

@ -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);

View file

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