From 5d47fd1e1176fca22044dd170f2e9caa7a337377 Mon Sep 17 00:00:00 2001 From: safe4u Date: Sun, 7 Jul 2024 20:09:27 +0800 Subject: [PATCH] fix unsoundness of RootMoveList --- pleco_engine/src/root_moves/root_moves_list.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pleco_engine/src/root_moves/root_moves_list.rs b/pleco_engine/src/root_moves/root_moves_list.rs index 1f64b78..4d3a444 100644 --- a/pleco_engine/src/root_moves/root_moves_list.rs +++ b/pleco_engine/src/root_moves/root_moves_list.rs @@ -93,6 +93,7 @@ impl RootMoveList { #[inline] pub fn insert_score_depth(&mut self, index: usize, score: i32, depth: i16) { + debug_assert!(index < self.len()); unsafe { let rm: &mut RootMove = self.get_unchecked_mut(index); rm.score = score; @@ -102,6 +103,7 @@ impl RootMoveList { #[inline] pub fn insert_score(&mut self, index: usize, score: i32) { + debug_assert!(index < self.len()); unsafe { let rm: &mut RootMove = self.get_unchecked_mut(index); rm.score = score;