Rollup merge of #78602 - RalfJung:raw-ptr-aliasing-issues, r=m-ou-se
fix various aliasing issues in the standard library This fixes various cases where the standard library either used raw pointers after they were already invalidated by using the original reference again, or created raw pointers for one element of a slice and used it to access neighboring elements.
This commit is contained in:
commit
8ed31d2782
5 changed files with 17 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue