Fix a few array out of bounds accesses (fixes #806).

Note that this applies to mainline too, not just libretro.
This commit is contained in:
Stephen Anthony 2022-05-29 16:40:17 -02:30
parent b70906c95f
commit 53dba3bba9
3 changed files with 5 additions and 6 deletions

View File

@ -21,6 +21,7 @@
srcdir ?= . srcdir ?= .
# -Wp,-D_GLIBCXX_ASSERTIONS
DEFINES := -DSDL_SUPPORT -D_GLIBCXX_USE_CXX11_ABI=1 DEFINES := -DSDL_SUPPORT -D_GLIBCXX_USE_CXX11_ABI=1
LDFLAGS := -pthread LDFLAGS := -pthread
INCLUDES := INCLUDES :=

View File

@ -300,7 +300,7 @@ class CartDebug : public DebuggerSystem
struct ReservedEquates { struct ReservedEquates {
std::array<bool, 16> TIARead; std::array<bool, 16> TIARead;
std::array<bool, 64> TIAWrite; std::array<bool, 64> TIAWrite;
std::array<bool, 24> IOReadWrite; std::array<bool, 32> IOReadWrite;
std::array<bool, 128> ZPRAM; std::array<bool, 128> ZPRAM;
AddrToLabel Label{}; AddrToLabel Label{};
bool breakFound{false}; bool breakFound{false};

View File

@ -133,15 +133,13 @@ void Cartridge::pokeRAM(uInt8& dest, uInt16 address, uInt8 value)
void Cartridge::createRomAccessArrays(size_t size) void Cartridge::createRomAccessArrays(size_t size)
{ {
myAccessSize = static_cast<uInt32>(size); myAccessSize = static_cast<uInt32>(size);
#ifdef DEBUGGER_SUPPORT
// Always create ROM access base even if DEBUGGER_SUPPORT is disabled,
// since other parts of the code depend on it existing
myRomAccessBase = make_unique<Device::AccessFlags[]>(size); myRomAccessBase = make_unique<Device::AccessFlags[]>(size);
std::fill_n(myRomAccessBase.get(), size, Device::ROW); std::fill_n(myRomAccessBase.get(), size, Device::ROW);
myRomAccessCounter = make_unique<Device::AccessCounter[]>(size * 2); myRomAccessCounter = make_unique<Device::AccessCounter[]>(size * 2);
std::fill_n(myRomAccessCounter.get(), size * 2, 0); std::fill_n(myRomAccessCounter.get(), size * 2, 0);
#else
myRomAccessBase = nullptr;
myRomAccessCounter = nullptr;
#endif
} }
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT