1
Fork 0

fix aliasing issue in binary_heap

This commit is contained in:
Ralf Jung 2020-10-31 16:22:24 +01:00
parent 9f630af930
commit 607076e209

View file

@ -1036,8 +1036,9 @@ impl<'a, T> Hole<'a, T> {
debug_assert!(index != self.pos); debug_assert!(index != self.pos);
debug_assert!(index < self.data.len()); debug_assert!(index < self.data.len());
unsafe { unsafe {
let index_ptr: *const _ = self.data.get_unchecked(index); let ptr = self.data.as_mut_ptr();
let hole_ptr = self.data.get_unchecked_mut(self.pos); let index_ptr: *const _ = ptr.add(index);
let hole_ptr = ptr.add(self.pos);
ptr::copy_nonoverlapping(index_ptr, hole_ptr, 1); ptr::copy_nonoverlapping(index_ptr, hole_ptr, 1);
} }
self.pos = index; self.pos = index;