mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Clamp reads at the beginning too.
Safer, avoids an index overrun in disk cache.
This commit is contained in:
parent
1c357f7f7b
commit
8dd7527dc8
2 changed files with 12 additions and 0 deletions
|
@ -68,6 +68,12 @@ void CachingFileLoader::Seek(s64 absolutePos) {
|
|||
}
|
||||
|
||||
size_t CachingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data) {
|
||||
if (absolutePos >= filesize_) {
|
||||
bytes = 0;
|
||||
} else if (absolutePos + (s64)bytes >= filesize_) {
|
||||
bytes = filesize_ - absolutePos;
|
||||
}
|
||||
|
||||
size_t readSize = ReadFromCache(absolutePos, bytes, data);
|
||||
// While in case the cache size is too small for the entire read.
|
||||
while (readSize < bytes) {
|
||||
|
|
|
@ -76,6 +76,12 @@ void DiskCachingFileLoader::Seek(s64 absolutePos) {
|
|||
size_t DiskCachingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data) {
|
||||
size_t readSize;
|
||||
|
||||
if (absolutePos >= filesize_) {
|
||||
bytes = 0;
|
||||
} else if (absolutePos + (s64)bytes >= filesize_) {
|
||||
bytes = filesize_ - absolutePos;
|
||||
}
|
||||
|
||||
if (cache_ && cache_->IsValid()) {
|
||||
readSize = cache_->ReadFromCache(absolutePos, bytes, data);
|
||||
// While in case the cache size is too small for the entire read.
|
||||
|
|
Loading…
Add table
Reference in a new issue