better name for check_in_alloc
This commit is contained in:
parent
3677c5be56
commit
e4c39e1bc2
2 changed files with 6 additions and 3 deletions
|
|
@ -191,8 +191,11 @@ impl<'tcx, Tag> Pointer<Tag> {
|
|||
Pointer { alloc_id: self.alloc_id, offset: self.offset, tag: () }
|
||||
}
|
||||
|
||||
/// Test if the pointer is "inbounds" of an allocation of the given size.
|
||||
/// A pointer is "inbounds" even if its offset is equal to the size; this is
|
||||
/// a "one-past-the-end" pointer.
|
||||
#[inline(always)]
|
||||
pub fn check_in_alloc(
|
||||
pub fn check_inbounds_alloc(
|
||||
self,
|
||||
allocation_size: Size,
|
||||
msg: CheckInAllocMsg,
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||
// It is sufficient to check this for the end pointer. The addition
|
||||
// checks for overflow.
|
||||
let end_ptr = ptr.offset(size, self)?;
|
||||
end_ptr.check_in_alloc(allocation_size, CheckInAllocMsg::MemoryAccessTest)?;
|
||||
end_ptr.check_inbounds_alloc(allocation_size, CheckInAllocMsg::MemoryAccessTest)?;
|
||||
// Test align. Check this last; if both bounds and alignment are violated
|
||||
// we want the error to be about the bounds.
|
||||
if alloc_align.bytes() < align.bytes() {
|
||||
|
|
@ -387,7 +387,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||
) -> bool {
|
||||
let (size, _align) = self.get_size_and_align(ptr.alloc_id, AllocCheck::MaybeDead)
|
||||
.expect("alloc info with MaybeDead cannot fail");
|
||||
ptr.check_in_alloc(size, CheckInAllocMsg::NullPointerTest).is_err()
|
||||
ptr.check_inbounds_alloc(size, CheckInAllocMsg::NullPointerTest).is_err()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue