]> git.sesse.net Git - stockfish/blobdiff - src/uci.cpp
Validate input UCI moves
[stockfish] / src / uci.cpp
index 39270c6ff93697b1ff3206f4022637be613fecad..673d661878a7b1b12ea687c9f9f9909bc355b227 100644 (file)
@@ -120,6 +120,7 @@ namespace {
 
   void set_position(Position& pos, UCIParser& up) {
 
+    Move m;
     string token, fen;
 
     up >> token; // operator>>() skips any whitespace
@@ -139,8 +140,8 @@ namespace {
     else return;
 
     // Parse move list (if any)
-    while (up >> token)
-        pos.do_setup_move(move_from_uci(pos, token));
+    while (up >> token && (m = move_from_uci(pos, token)) != MOVE_NONE)
+        pos.do_setup_move(m);
   }
 
 
@@ -216,15 +217,13 @@ namespace {
     limits.time = time[pos.side_to_move()];
     limits.increment = inc[pos.side_to_move()];
 
-    assert(pos.is_ok());
-
     return think(pos, limits, searchMoves);
   }
 
 
   // perft() is called when engine receives the "perft" command.
   // The function calls perft() passing the required search depth
-  // then prints counted nodes and elapsed time.
+  // then prints counted leaf nodes and elapsed time.
 
   void perft(Position& pos, UCIParser& up) {