Skip to content

Commit

Permalink
Merge pull request #18896 from rofl0r/fixfscrash
Browse files Browse the repository at this point in the history
FS: fix crash overreading data on flash0
  • Loading branch information
hrydgard committed Feb 27, 2024
2 parents 3d58d1f + 55ae3b1 commit d24f972
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Core/FileSystems/DirectoryFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d24f972

Please sign in to comment.