From 2c21cc66515e6b4bf3fa4d6970fc5eea9a2344db Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 12 Oct 2011 17:28:48 +0200 Subject: [PATCH] Fix crash on loading garbage game file The code to cache games was not resistant to moves before a valid game start, or a game filewithout any games at all. --- gamelist.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/gamelist.c b/gamelist.c index fb10fbe..188fdf6 100644 --- a/gamelist.c +++ b/gamelist.c @@ -342,7 +342,7 @@ struct { toY = currentMoveString[3] - ONE; plyNr++; ApplyMove(fromX, fromY, toX, toY, currentMoveString[4], boards[scratch]); - if(currentListGame->moves) PackMove(fromX, fromY, toX, toY, boards[scratch][toY][toX]); + if(currentListGame && currentListGame->moves) PackMove(fromX, fromY, toX, toY, boards[scratch][toY][toX]); break; case WhiteWins: // [HGM] rescom: save last comment as result details case BlackWins: @@ -368,6 +368,7 @@ struct { } while (cm != (ChessMove) 0); + if(currentListGame) { if(!currentListGame->moves) DisplayError("Game cache overflowed\nPosition-searching might not work properly", 0); if (appData.debugMode) { @@ -380,6 +381,7 @@ struct { PrintPGNTags(debugFP, ¤tListGame->gameInfo); } } + } GetTimeMark(&t2);printf("GameListBuild %d msec\n", SubtractTimeMarks(&t2,&t)); quickFlag = 0; PackGame(boards[scratch]); // for appending end-of-game marker. -- 1.7.0.4