fix some uses of pointer intrinsics with invalid pointers
This commit is contained in:
parent
29e6aabceb
commit
61f0a2b3fd
2 changed files with 7 additions and 7 deletions
|
@ -2410,9 +2410,8 @@ impl<T> Iterator for IntoIter<T> {
|
|||
// same pointer.
|
||||
self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T;
|
||||
|
||||
// Use a non-null pointer value
|
||||
// (self.ptr might be null because of wrapping)
|
||||
Some(ptr::read(1 as *mut T))
|
||||
// Read from a properly aligned pointer to make up a value of this ZST.
|
||||
Some(ptr::read(NonNull::dangling().as_ptr()))
|
||||
} else {
|
||||
let old = self.ptr;
|
||||
self.ptr = self.ptr.offset(1);
|
||||
|
@ -2451,9 +2450,8 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
|
|||
// See above for why 'ptr.offset' isn't used
|
||||
self.end = arith_offset(self.end as *const i8, -1) as *mut T;
|
||||
|
||||
// Use a non-null pointer value
|
||||
// (self.end might be null because of wrapping)
|
||||
Some(ptr::read(1 as *mut T))
|
||||
// Read from a properly aligned pointer to make up a value of this ZST.
|
||||
Some(ptr::read(NonNull::dangling().as_ptr()))
|
||||
} else {
|
||||
self.end = self.end.offset(-1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue