mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Don't read past the end of sce_lbn files on virtual discs
This commit is contained in:
parent
83f81eaaf1
commit
efa2566192
1 changed files with 7 additions and 0 deletions
|
@ -493,6 +493,13 @@ size_t VirtualDiscFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &u
|
|||
return size;
|
||||
}
|
||||
|
||||
if (iter->second.type == VFILETYPE_LBN && iter->second.curOffset + size > iter->second.size) {
|
||||
// Clamp to the remaining size, but read what we can.
|
||||
const s64 newSize = iter->second.size - iter->second.curOffset;
|
||||
WARN_LOG(FILESYS, "VirtualDiscFileSystem: Reading beyond end of file, clamping size %lld to %lld", size, newSize);
|
||||
size = newSize;
|
||||
}
|
||||
|
||||
size_t bytesRead = iter->second.Read(pointer, size);
|
||||
iter->second.curOffset += bytesRead;
|
||||
return bytesRead;
|
||||
|
|
Loading…
Add table
Reference in a new issue