]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Fix a subtle bug due to the StateInfo pointer became stale
[stockfish] / src / position.cpp
index 0a275b5ee3bdc4e7dfb48fe3b8e8d2f835cced48..7725b934e1eb34824789ae7cbdeaf54078ab53fb 100644 (file)
@@ -1662,6 +1662,18 @@ int Position::see(Square from, Square to) const {
 }
 
 
+/// Position::setStartState() copies the content of the argument
+/// inside startState and makes st point to it. This is needed
+/// when the st pointee could become stale, as example because
+/// the caller is about to going out of scope.
+
+void Position::setStartState(const StateInfo& s) {
+
+  startState = s;
+  st = &startState;
+}
+
+
 /// Position::clear() erases the position object to a pristine state, with an
 /// empty board, white to move, and no castling rights.