You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IntoIter::{as_slice, clone, ..} materialize &[T] over moved out prefix slots, leading to undefined behavior #331
Say, T is Box<i32> which makes this UB bit more clear.
Say we do .next() a few times. Then slots 0..self.index in IntoIter are logically moved-out. Referencing them is UB i.e. holding Box pointers after drop or aliased copies of live reference)
Safe functions IntoIter::{as_slice, as_mut_slice, clone, fmt} evaluate &self.v[self.index..] or &mut self.v[self.index..]. ArrayVec does not implement Index<RangeFrom<usize>>, only slices [T] do. So before Rust can apply [self.index..], it has to convert &self.v into a &[T] via Deref::deref(&self.v). This leads to UB.
Activity
Fix UB in IntoIter slice, clone, and Debug methods
Fix UB in IntoIter slice, clone, and Debug methods