mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Validate input UCI moves
Running following command: position startpos moves e1e8 Makes SF to assert in debug mode in do_move() but to accept bad input and continue in release mode where probably it is going to crash little later. So validate input before to feed do_move(). Suggestion by Yakovlev Vadim. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user