Merge pull request #18896 from rofl0r/fixfscrash

FS: fix crash overreading data on flash0
This commit is contained in:
Henrik Rydgård 2024-02-27 11:28:53 +07:00 committed by GitHub
commit d24f972468
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1067,6 +1067,9 @@ size_t VFSFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) {
EntryMap::iterator iter = entries.find(handle);
if (iter != entries.end())
{
if(iter->second.seekPos + size > iter->second.size)
size = iter->second.size - iter->second.seekPos;
if(size < 0) size = 0;
size_t bytesRead = size;
memcpy(pointer, iter->second.fileData + iter->second.seekPos, size);
iter->second.seekPos += size;