Fix crash on loading garbage game file
authorH.G. Muller <h.g.muller@hccnet.nl>
Wed, 12 Oct 2011 15:23:57 +0000 (17:23 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Wed, 12 Oct 2011 15:56:40 +0000 (17:56 +0200)
XBoard crashed when a game file contained a PGN game result before
any valid game start, because data would be written in a game-list
node that did not exist yet. This would occur frequently when garage
was read; basically any asterisk in the data would do it.

gamelist.c

index 2626839..a36af7a 100644 (file)
@@ -304,6 +304,7 @@ int GameListBuild(f)
         case BlackWins:
         case GameIsDrawn:
         case GameUnfinished:
+           if(!currentListGame) break;
            if (currentListGame->gameInfo.resultDetails != NULL) {
                free(currentListGame->gameInfo.resultDetails);
            }