mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
GameInfoCache: Check read size before using the data.
This commit is contained in:
1 parent
039fb86e9c
commit
f0af76ec40
1 file changed
+8
-3
@@ -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