diff options
| author | Ralf Jung <post@ralfj.de> | 2020-10-31 16:22:24 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-10-31 16:26:06 +0100 |
| commit | 607076e20903bb5267d5d8f2bc7520ba1686cec8 (patch) | |
| tree | c7715f63d3f5f18cf5b4b5aa7cba7450588f5d9d | |
| parent | 9f630af93077b276f78701dcd2307d19dccf0e14 (diff) | |
| download | rust-607076e20903bb5267d5d8f2bc7520ba1686cec8.tar.gz rust-607076e20903bb5267d5d8f2bc7520ba1686cec8.zip | |
fix aliasing issue in binary_heap
| -rw-r--r-- | library/alloc/src/collections/binary_heap.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index f2852b1cc2b..b67c72d7136 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -1036,8 +1036,9 @@ impl<'a, T> Hole<'a, T> { debug_assert!(index != self.pos); debug_assert!(index < self.data.len()); unsafe { - let index_ptr: *const _ = self.data.get_unchecked(index); - let hole_ptr = self.data.get_unchecked_mut(self.pos); + let ptr = self.data.as_mut_ptr(); + let index_ptr: *const _ = ptr.add(index); + let hole_ptr = ptr.add(self.pos); ptr::copy_nonoverlapping(index_ptr, hole_ptr, 1); } self.pos = index; |
