Fix a crash issue when traversing PVs.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 15 Nov 2016 21:03:15 +0000 (22:03 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 24 Nov 2018 10:17:41 +0000 (11:17 +0100)
src/main.cpp

index de220ee..76aca51 100644 (file)
@@ -119,7 +119,9 @@ void HashProbeImpl::ProbeMove(Position* pos, std::deque<StateInfo>* setup_states
                // Follow the PV until we hit an illegal move.
                std::stack<Move> pv;
                std::set<Key> seen;
-               while (found && is_ok(entry->move())) {
+               while (found && is_ok(entry->move()) &&
+                      pos->pseudo_legal(entry->move()) &&
+                      pos->legal(entry->move())) {
                        FillMove(entry->move(), response->add_pv());
                        if (seen.count(pos->key())) break;
                        pv.push(entry->move());