1
0
Fork 0
forked from len0rd/rockbox

Fix for Chessbox bug FS#10363

Chessbox was overflowing GameList[240] causing the board to flip + crash

GameCnt changed to unsigned char which allows the array to roll over
to 0 after 255

define MAX_GAME_CNT 256 and GameList[MAX_GAME_CNT] along with 1 byte GameCnt
should fix this issue

dbg save routine left in for now to help identify any other problems

Added bounds checking to prevent second bug found when loading .pgn files

Change-Id: I2b615c8ecbed4368724412f80ce07346f3cf30a7
This commit is contained in:
William Wilgus 2017-01-31 04:28:02 +01:00
parent 37522ec63a
commit 1fa7c56351
4 changed files with 164 additions and 34 deletions

View file

@ -1,7 +1,7 @@
#ifndef _GNUCHESS_H_
#define _GNUCHESS_H_
#define MAX_GAME_CNT 256
#define neutral 2
#define white 0
#define black 1
@ -39,9 +39,10 @@ extern bool withbook;
extern long Level;
extern short TCflag,TCmoves,TCminutes;
extern short timeout;
extern short GameCnt,Game50,castld[2],kingmoved[2],OperatorTime;
extern unsigned char GameCnt; /* Bug fix rolls over at 255 instead of overflow */
extern short Game50,castld[2],kingmoved[2],OperatorTime;
extern struct TimeControlRec TimeControl;
extern struct GameRec GameList[240];
extern struct GameRec GameList[MAX_GAME_CNT];
/* ---- The beginning of a GNUChess v2 APIfication ---- */
void SetTimeControl(void);