Fix undefined behavior when indexing into ARCode::Code (#2331)

- Indexing past the end of a `std::vector`'s length is undefined, even if there's extra capacity
- GCC 15 introduced an assert in `vector::operator[]`, so this line caused an abort if melonDS was built with GCC 15
- It was always undefined, but now the STL checks for it
This commit is contained in:
Jesse Talavera
2025-05-19 19:00:48 -04:00
committed by GitHub
parent 0e64a06c84
commit 7baeb26e32

View File

@ -58,7 +58,8 @@ void AREngine::RunCheat(const ARCode& arcode)
for (;;) for (;;)
{ {
if (code >= &arcode.Code[arcode.Code.size()]) if (code > &arcode.Code[arcode.Code.size() - 1])
// If the instruction pointer is past the end of the cheat code...
break; break;
u32 a = *code++; u32 a = *code++;