From 4509eb1342fe282d08bd90340efaff4df5947a87 Mon Sep 17 00:00:00 2001 From: Gary Linscott Date: Mon, 24 Nov 2014 08:53:00 +0800 Subject: [PATCH] Fix out-of-bound array access printing ponder move It is possible that we won't have a ponder move if our PV is too short. In that case, just don't print a ponder move. No functional change Resolves #130 --- src/search.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 9f278623..11ba939a 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -217,9 +217,12 @@ void Search::think() { RootPos.this_thread()->wait_for(Signals.stop); } - sync_cout << "bestmove " << UCI::format_move(RootMoves[0].pv[0], RootPos.is_chess960()) - << " ponder " << UCI::format_move(RootMoves[0].pv[1], RootPos.is_chess960()) - << sync_endl; + sync_cout << "bestmove " << UCI::format_move(RootMoves[0].pv[0], RootPos.is_chess960()); + + if (RootMoves[0].pv.size() > 1) + std::cout << " ponder " << UCI::format_move(RootMoves[0].pv[1], RootPos.is_chess960()); + + std::cout << sync_endl; } -- 2.39.2