mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix buffer overflow in RAM caching feature.
Would mainly affect files not even block sizes, such as CSO files, but might affect all files. Oops. Fixes #8764.
This commit is contained in:
parent
bb7dd908ba
commit
546c0a5d9b
1 changed files with 4 additions and 4 deletions
|
@ -90,13 +90,13 @@ size_t RamCachingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data) {
|
|||
}
|
||||
|
||||
void RamCachingFileLoader::InitCache() {
|
||||
cache_ = (u8 *)malloc(filesize_);
|
||||
lock_guard guard(blocksMutex_);
|
||||
u32 blockCount = (u32)((filesize_ + BLOCK_SIZE - 1) >> BLOCK_SHIFT);
|
||||
// Overallocate for the last block.
|
||||
cache_ = (u8 *)malloc((size_t)blockCount << BLOCK_SHIFT);
|
||||
if (cache_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
lock_guard guard(blocksMutex_);
|
||||
u32 blockCount = (u32)((filesize_ + BLOCK_SIZE - 1) >> BLOCK_SHIFT);
|
||||
aheadRemaining_ = blockCount;
|
||||
blocks_.resize(blockCount);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue