This commit is contained in:
thrust26 2025-01-01 09:50:33 +01:00
parent 9b0c8c18de
commit 34e4439729
1 changed files with 12 additions and 2 deletions

View File

@ -827,9 +827,19 @@ ByteBuffer OSystem::openROM(const FSNode& rom, size_t& size,
// Next check for a proper file size
// Streaming ROMs read only a portion of the file
// Otherwise the size to read is 0 (meaning read the entire file)
const size_t sizeToRead = CartDetector::isProbablyMVC(rom);
size_t sizeToRead = 0;
try
{
sizeToRead = CartDetector::isProbablyMVC(rom);
}
catch(const runtime_error&)
{
if(showErrorMessage)
throw runtime_error("File not found/readable");
else
return nullptr;
}
const bool isStreaming = sizeToRead > 0;
// Make sure we only read up to the maximum supported cart size
const bool isValidSize = isValidROM && (isStreaming ||
rom.getSize() <= Cartridge::maxSize());