From cf26b3e8a4d056c93860f4292d9cd5fc5cb00890 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Thu, 16 Oct 2014 17:54:13 +0200 Subject: [PATCH] Fix some uninitialized variable bugs The writing of Seirawan castling rights in FEN was still dependent on a now unused variable, and encountering a VariantMen tag in a PGN file could have created the misconception the memory was full. --- backend.c | 4 ++-- moves.c | 2 +- pgntags.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index 878f03f..e50e869 100644 --- a/backend.c +++ b/backend.c @@ -17871,7 +17871,7 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) q = (boards[move][CASTLING][1] == BOARD_LEFT && boards[move][CASTLING][2] != NoRights ); if(handW) { // for S-Chess with pieces in hand, list virgin pieces between K and Q - for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q && j; i--) + for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q; i--) if((boards[move][0][i] != WhiteKing || k+q == 0) && boards[move][VIRGIN][i] & VIRGIN_W) *p++ = i + AAA + 'A' - 'a'; } @@ -17882,7 +17882,7 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) q = (boards[move][CASTLING][4] == BOARD_LEFT && boards[move][CASTLING][5] != NoRights ); if(handB) { - for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q && j; i--) + for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q; i--) if((boards[move][BOARD_HEIGHT-1][i] != BlackKing || k+q == 0) && boards[move][VIRGIN][i] & VIRGIN_B) *p++ = i + AAA; } diff --git a/moves.c b/moves.c index aca97b5..4279ce9 100644 --- a/moves.c +++ b/moves.c @@ -268,7 +268,7 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle int mine, his, dir, bit, occup, i; if(flags & F_WHITE_ON_MOVE) his = 2, mine = 1; else his = 1, mine = 2; while(*p) { // more moves to go - int expo = 1, dx, dy, x, y, mode, dirSet, ds2, retry=0, initial=0, jump=1, skip = 0, all = 0; + int expo = 1, dx, dy, x, y, mode, dirSet, ds2=0, retry=0, initial=0, jump=1, skip = 0, all = 0; char *cont = NULL; if(*p == 'i') initial = 1, desc = ++p; while(islower(*p)) p++; // skip prefixes diff --git a/pgntags.c b/pgntags.c index f13eb96..616303d 100644 --- a/pgntags.c +++ b/pgntags.c @@ -119,6 +119,7 @@ ParsePGNTag (char *tag, GameInfo *gameInfo) } else if (StrCaseCmp(name, "VariantMen") == 0) { /* for now ignore this tag, as we have no method yet */ /* for assigning the pieces to XBoard pictograms */ + success = TRUE; } else if (StrCaseCmp(name, PGN_OUT_OF_BOOK) == 0) { /* [AS] Out of book annotation */ success = StrSavePtr(value, &gameInfo->outOfBook) != NULL; -- 1.7.0.4