Fix reads from cache outside the file.

Homebrew seems to all trigger us to read after the end of file, which was
looping infinitely.  Fixes #8773.
This commit is contained in:
Unknown W. Brackets committed 2016-05-25 18:42:21 -07:00
1 parent 8d87a5b7a2
commit 1c357f7f7b
3 files changed
+19 -4

No files matched your search

+6 -1
View File
@@ -72,7 +72,12 @@ size_t CachingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data) {
// While in case the cache size is too small for the entire read.
while (readSize < bytes) {
SaveIntoCache(absolutePos + readSize, bytes - readSize);
readSize += ReadFromCache(absolutePos + readSize, bytes - readSize, (u8 *)data + readSize);
size_t bytesFromCache = ReadFromCache(absolutePos + readSize, bytes - readSize, (u8 *)data + readSize);
readSize += bytesFromCache;
if (bytesFromCache == 0) {
// We can't read any more.
break;
}
}
StartReadAhead(absolutePos + readSize);