Skip to content

Commit

Permalink
fixed #1053
Browse files Browse the repository at this point in the history
  • Loading branch information
thrust26 committed Jan 1, 2025
1 parent 4c27009 commit 1c7bafb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/emucore/OSystem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 1c7bafb

Please sign in to comment.