]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Do not crash if we are asked to search mate or stalemate position.
[stockfish] / src / search.cpp
index b86693289c8b2688070e74382a1b64c286528af2..4b93a210b59ed218c3d7081653e736801eb6f391 100644 (file)
@@ -677,6 +677,14 @@ namespace {
     // searchMoves are verified, copied, scored and sorted
     RootMoveList rml(p, searchMoves);
 
+    if (rml.move_count() == 0)
+    {
+        if (PonderSearch)
+            wait_for_stop_or_ponderhit();
+
+        return pos.is_check()? -VALUE_MATE : VALUE_DRAW;
+    }
+
     // Print RootMoveList c'tor startup scoring to the standard output,
     // so that we print information also for iteration 1.
     std::cout << "info depth " << 1 << "\ninfo depth " << 1