]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Fix memory access in Search::clear()
[stockfish] / src / search.cpp
index e8e15ef2cf58826edff4c82b9a9d97ce948fe384..de487e57b2d000768842b98384402921e8a95261 100644 (file)
@@ -197,9 +197,10 @@ void Search::clear() {
       th->history.clear();
       th->counterMoveHistory.clear();
       th->resetCalls = true;
       th->history.clear();
       th->counterMoveHistory.clear();
       th->resetCalls = true;
+
       CounterMoveStats& cm = th->counterMoveHistory[NO_PIECE][0];
       CounterMoveStats& cm = th->counterMoveHistory[NO_PIECE][0];
-      int* t = &cm[NO_PIECE][0];
-      std::fill(t, t + sizeof(cm), CounterMovePruneThreshold - 1);
+      auto* t = &cm[NO_PIECE][0];
+      std::fill(t, t + sizeof(cm)/sizeof(*t), CounterMovePruneThreshold - 1);
   }
 
   Threads.main()->previousScore = VALUE_INFINITE;
   }
 
   Threads.main()->previousScore = VALUE_INFINITE;