From dcbff3f40b023802c9aac457f258e8c065fa4ce2 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 27 Dec 2009 18:57:10 +0000 Subject: [PATCH] fix crash/freeze when adding internal cheats [2921845] --- desmume/src/cheatSystem.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index 264f809b9..1f2363a0c 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -557,13 +557,17 @@ BOOL CHEATS::save() for (int t = 0; t < list[i].num; t++) { char buf2[10] = { 0 }; + + u32 adr = list[i].code[t][0]; if (list[i].type == 0) { - list[i].code[t][0] &= 0x0FFFFFFF; - list[i].code[t][0] |= (list[i].size << 28); + //size of the cheat is written out as adr highest nybble + adr &= 0x0FFFFFFF; + adr |= (list[i].size << 28); } - sprintf(buf2, "%08X", list[i].code[t][0]); + sprintf(buf2, "%08X", adr); strcat(buf, buf2); + sprintf(buf2, "%08X", list[i].code[t][1]); strcat(buf, buf2); if (t < (list[i].num - 1))