GameList: Fix crash if cache fails to open

This commit is contained in:
Stenzek 2025-03-28 17:07:13 +10:00
parent ece18d10c5
commit ceef7af1da
No known key found for this signature in database
2 changed files with 3 additions and 1 deletions

View File

@ -289,7 +289,7 @@ BinaryFileReader& BinaryFileReader::operator=(BinaryFileReader&& move)
bool BinaryFileReader::IsAtEnd()
{
return (FileSystem::FTell64(m_fp) == m_size);
return (!m_fp || FileSystem::FTell64(m_fp) == m_size);
}
bool BinaryFileReader::ReadCString(std::string* dst)

View File

@ -495,6 +495,8 @@ bool GameList::LoadOrInitializeCache(std::FILE* fp, bool invalidate_cache)
WARNING_LOG("Initializing game list cache.");
s_cache_map.clear();
if (!fp)
return false;
// Truncate file, and re-write header.
Error error;