mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
GameInfoCache: Check read size before using the data.
This commit is contained in:
@@ -351,15 +351,20 @@ static bool ReadFileToString(IFileSystem *fs, const char *filename, std::string
|
||||
if (mtx) {
|
||||
std::string data;
|
||||
data.resize(info.size);
|
||||
fs->ReadFile(handle, (u8 *)data.data(), info.size);
|
||||
size_t readSize = fs->ReadFile(handle, (u8 *)data.data(), info.size);
|
||||
fs->CloseFile(handle);
|
||||
|
||||
if (readSize != info.size) {
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(*mtx);
|
||||
*contents = std::move(data);
|
||||
} else {
|
||||
contents->resize(info.size);
|
||||
fs->ReadFile(handle, (u8 *)contents->data(), info.size);
|
||||
size_t readSize = fs->ReadFile(handle, (u8 *)contents->data(), info.size);
|
||||
fs->CloseFile(handle);
|
||||
if (readSize != info.size) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user