From 5893dc78f3edd9bdb2f84f29bfadbff77f04e726 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 26 Jul 2017 23:48:50 -0500 Subject: [PATCH] action replay - attempt to avoid running off the end of cheat codes and crashing in case of invalid codes (fixes #78) --- desmume/src/cheatSystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index a882faa10..d60f79fab 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -542,6 +542,7 @@ void CHEATS::ARparser(CHEATS_LIST& list) if(y>0) i++; //skip over the current code while(y>=4) { + if(i==list.num) break; //if we erroneously went off the end, bail u32 tmp = list.code[i][t]; if(t==1) i++; t ^= 1; @@ -551,6 +552,7 @@ void CHEATS::ARparser(CHEATS_LIST& list) } while(y>0) { + if(i==list.num) break; //if we erroneously went off the end, bail u32 tmp = list.code[i][t]>>b; CheatWrite(8,st.proc,addr,tmp); addr += 1; @@ -576,6 +578,7 @@ void CHEATS::ARparser(CHEATS_LIST& list) operand = x; //mis-use of this variable to store dst while(y>=4) { + if(i==list.num) break; //if we erroneously went off the end, bail u32 tmp = _MMU_read32(st.proc,MMU_AT_DEBUG,addr); CheatWrite(32, st.proc,operand,tmp); addr += 4; @@ -584,6 +587,7 @@ void CHEATS::ARparser(CHEATS_LIST& list) } while(y>0) { + if(i==list.num) break; //if we erroneously went off the end, bail u8 tmp = _MMU_read08(st.proc,MMU_AT_DEBUG,addr); CheatWrite(8,st.proc,operand,tmp); addr += 1;