diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 5b4b0b0dc..658379b68 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -7973,7 +7973,8 @@ static void end_cheat(void) KB_FlushKeyboardQueue(); } -static int8_t cheatbuf[MAXCHEATLEN], cheatbuflen; +static int32_t cheatbuflen; +static int8_t cheatbuf[MAXCHEATLEN]; GAME_STATIC void G_DoCheats(void) { @@ -8016,15 +8017,12 @@ GAME_STATIC void G_DoCheats(void) } cheatbuf[cheatbuflen++] = (int8_t)ch; + // This assertion is not obvious, but it should hold because of the + // cheat string matching logic below. + Bassert(cheatbuflen < (signed)sizeof(cheatbuf)); cheatbuf[cheatbuflen] = 0; // KB_ClearKeysDown(); - if (cheatbuflen > MAXCHEATLEN) - { - g_player[myconnectindex].ps->cheat_phase = 0; - return; - } - for (k=0; k < NUMCHEATCODES; k++) { for (j = 0; j= (signed)sizeof(CheatStrings[k])-1) { initprintf("%s:%d: warning: truncating cheat string to %d characters.\n", - g_szScriptFileName,g_lineNumber,MAXCHEATLEN); //,sizeof(CheatStrings[k])-1); + g_szScriptFileName,g_lineNumber,(signed)sizeof(CheatStrings[k])-1); g_numCompilerWarnings++; C_NextLine(); break;