Skip to content

Commit 607076e

Browse files
committed
fix aliasing issue in binary_heap
1 parent 9f630af commit 607076e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/alloc/src/collections/binary_heap.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,9 @@ impl<'a, T> Hole<'a, T> {
10361036
debug_assert!(index != self.pos);
10371037
debug_assert!(index < self.data.len());
10381038
unsafe {
1039-
let index_ptr: *const _ = self.data.get_unchecked(index);
1040-
let hole_ptr = self.data.get_unchecked_mut(self.pos);
1039+
let ptr = self.data.as_mut_ptr();
1040+
let index_ptr: *const _ = ptr.add(index);
1041+
let hole_ptr = ptr.add(self.pos);
10411042
ptr::copy_nonoverlapping(index_ptr, hole_ptr, 1);
10421043
}
10431044
self.pos = index;

0 commit comments

Comments
 (0)