From f09b391ceb5ea282538b721b069db67e3b6e098f Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Tue, 27 Dec 2022 13:33:26 +0100 Subject: [PATCH] Fix comparison with uninitialized variable In both modified methods, the variable 'result' is checked to detect whether the probe operation failed. However, the variable is not initialized on all paths, so the check might test an uninitialized value. A test position (with TB) is given by: position fen 3K1k2/R7/8/8/8/8/8/R6Q w - - 0 1 moves a1b1 f8g8 b1a1 g8f8 a1b1 f8g8 b1a1 This is now fixed by always initializing the variable. closes https://github.com/official-stockfish/Stockfish/pull/4309 No functional change --- src/syzygy/tbprobe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index f2de036d..4df495a8 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -1514,7 +1514,7 @@ int Tablebases::probe_dtz(Position& pos, ProbeState* result) { // A return value false indicates that not all probes were successful. bool Tablebases::root_probe(Position& pos, Search::RootMoves& rootMoves) { - ProbeState result; + ProbeState result = OK; StateInfo st; // Obtain 50-move counter for the root position @@ -1593,7 +1593,7 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves) { static const int WDL_to_rank[] = { -MAX_DTZ, -MAX_DTZ + 101, 0, MAX_DTZ - 101, MAX_DTZ }; - ProbeState result; + ProbeState result = OK; StateInfo st; WDLScore wdl; -- 2.39.2