From a19be5da110ba927ea656ff5a21330d0ba88e8b3 Mon Sep 17 00:00:00 2001 From: auronandace Date: Sun, 22 Feb 2026 13:43:37 +0000 Subject: [PATCH] avoid direct indexing in AlignedBox --- src/common/aligned_box.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/aligned_box.rs b/src/common/aligned_box.rs index ae6ae86afe..578e0f5c96 100644 --- a/src/common/aligned_box.rs +++ b/src/common/aligned_box.rs @@ -116,8 +116,12 @@ impl Clone for AlignedBox<[T], ALIG fn clone(&self) -> Self { let mut new = Self::try_zeroed_slice(self.len()) .unwrap_or_else(|_| alloc::alloc::handle_alloc_error(self.layout())); - for i in 0..self.len() { - new[i].clone_from(&self[i]); + for (i, val) in self.iter().enumerate() { + if let Some(new_inner) = new.get_mut(i) { + new_inner.clone_from(val); + } else { + unreachable!(); + } } new }