From 34e44397290bb6d21587af5063bc2ce5b711b55b Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 1 Jan 2025 09:50:33 +0100 Subject: [PATCH] fixed #1053 --- src/emucore/OSystem.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 7c9efe4ef..c81b66251 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -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());