From cb1d35c288bd082523979f5dc95453c86eaba0bf Mon Sep 17 00:00:00 2001 From: Melefo <42809472+Melefo@users.noreply.github.com> Date: Wed, 23 Jun 2021 21:49:18 +0200 Subject: [PATCH] Checking rom size --- sources/APU/APU.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/APU/APU.cpp b/sources/APU/APU.cpp index c7b851b..6179c4e 100644 --- a/sources/APU/APU.cpp +++ b/sources/APU/APU.cpp @@ -828,6 +828,9 @@ namespace ComSquare::APU void APU::loadFromSPC(const std::shared_ptr& cartridge) { const uint8_t *data = cartridge->getData(); + uint24_t size = cartridge->getSize(); + if (size < 0x101C0) + throw InvalidAddress("Cartridge is not the right size", size); std::string song = std::string(reinterpret_cast(data + 0x2E), 0x20); std::string game = std::string(reinterpret_cast(data + 0x4E), 0x20);