mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00: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:
1 parent
bb7dd908ba
commit
546c0a5d9b
1 file changed
+4
-4
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user