]> git.sesse.net Git - stockfish/commitdiff
Fix use of uninitialized variable
authorMarco Costalba <mcostalba@gmail.com>
Fri, 12 Aug 2011 09:42:08 +0000 (11:42 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 12 Aug 2011 10:56:11 +0000 (11:56 +0100)
When initializing endgames map we build a faked FEN string
in mat_key() to get the position hash's key.

This fen string lacks full move numbers, so when parsing the
fen in Position::from_fen() we leave startPosPly un-initialized.

Spotted by Valgrind (this is a kind of bug that is almost impossible
for humans to find).

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/endgame.cpp

index c1c703a3af2ce80583e97b0201517bcbc4c0b7ab..f8f4c802d118441c09a5da4e405867605695a336 100644 (file)
@@ -87,7 +87,7 @@ namespace {
     do fen += char(tolower(keyCode[i])); while (++i < keyCode.length());
 
     // Add file padding and remaining empty ranks
     do fen += char(tolower(keyCode[i])); while (++i < keyCode.length());
 
     // Add file padding and remaining empty ranks
-    fen += string(1, '0' + int(8 - keyCode.length())) + "/8/8/8/8/8/8/8 w - -";
+    fen += string(1, '0' + int(8 - keyCode.length())) + "/8/8/8/8/8/8/8 w - - 0 10";
 
     // Build a Position out of the fen string and get its material key
     return Position(fen, false, 0).get_material_key();
 
     // Build a Position out of the fen string and get its material key
     return Position(fen, false, 0).get_material_key();