Check return value when calling ReadArray for savestates
Just in case we have a 0-byte file or something.
This commit is contained in:
parent
4597d53307
commit
abd069ada3
|
@ -455,11 +455,7 @@ bool ReadHeader(const std::string& filename, StateHeader& header)
|
||||||
{
|
{
|
||||||
Flush();
|
Flush();
|
||||||
File::IOFile f(filename, "rb");
|
File::IOFile f(filename, "rb");
|
||||||
if (!f)
|
return f.ReadArray(&header, 1);
|
||||||
return false;
|
|
||||||
|
|
||||||
f.ReadArray(&header, 1);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetInfoStringOfSlot(int slot, bool translate)
|
std::string GetInfoStringOfSlot(int slot, bool translate)
|
||||||
|
@ -490,15 +486,14 @@ static void LoadFileStateData(const std::string& filename, std::vector<u8>& ret_
|
||||||
{
|
{
|
||||||
Flush();
|
Flush();
|
||||||
File::IOFile f(filename, "rb");
|
File::IOFile f(filename, "rb");
|
||||||
if (!f)
|
|
||||||
|
StateHeader header;
|
||||||
|
if (!f.ReadArray(&header, 1))
|
||||||
{
|
{
|
||||||
Core::DisplayMessage("State not found", 2000);
|
Core::DisplayMessage("State not found", 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StateHeader header;
|
|
||||||
f.ReadArray(&header, 1);
|
|
||||||
|
|
||||||
if (strncmp(SConfig::GetInstance().GetGameID().c_str(), header.gameID, 6))
|
if (strncmp(SConfig::GetInstance().GetGameID().c_str(), header.gameID, 6))
|
||||||
{
|
{
|
||||||
Core::DisplayMessage(fmt::format("State belongs to a different game (ID {})",
|
Core::DisplayMessage(fmt::format("State belongs to a different game (ID {})",
|
||||||
|
|
Loading…
Reference in New Issue