mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 17:49:29 +01:00
ReadAt()'s contract is to return the number of bytes/units actually read. On every platform branch, an OS-level read failure (ReadFile returning FALSE, or pread/read returning -1) was fed straight into a division by `bytes` without checking for it first: - Windows explicitly returned (size_t)-1. - Elsewhere, the signed -1 from pread/read was implicitly converted to size_t (via the usual arithmetic conversions with the unsigned `bytes`) before the division, producing a huge bogus count instead of a small one. Every caller in the caching chain (CachingFileLoader, RamCachingFileLoader, RetryingFileLoader, ZipFileLoader's libzip source callback) loops on "did we get at least what we asked for", which a huge return value trivially satisfies - so a local I/O error (removable media ejected, a content-URI permission problem mid-read, etc.) would be reported as a fully successful read of whatever uninitialized memory happened to be in the destination buffer.