@@ -262,7 +262,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
262
262
Scalar :: Ptr ( ptr) => {
263
263
// check this is not NULL -- which we can ensure only if this is in-bounds
264
264
// of some (potentially dead) allocation.
265
- let align = self . check_bounds_ptr_maybe_dead ( ptr) ?;
265
+ let align = self . check_bounds_ptr ( ptr, InboundsCheck :: MaybeDead ) ?;
266
266
( ptr. offset . bytes ( ) , align)
267
267
}
268
268
Scalar :: Bits { bits, size } => {
@@ -297,17 +297,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
297
297
/// Check if the pointer is "in-bounds". Notice that a pointer pointing at the end
298
298
/// of an allocation (i.e., at the first *inaccessible* location) *is* considered
299
299
/// in-bounds! This follows C's/LLVM's rules.
300
- /// This function also works for deallocated allocations.
301
- /// Use `.get(ptr.alloc_id)?.check_bounds_ptr(ptr)` if you want to force the allocation
302
- /// to still be live.
303
300
/// If you want to check bounds before doing a memory access, better first obtain
304
301
/// an `Allocation` and call `check_bounds`.
305
- pub fn check_bounds_ptr_maybe_dead (
302
+ pub fn check_bounds_ptr (
306
303
& self ,
307
304
ptr : Pointer < M :: PointerTag > ,
305
+ liveness : InboundsCheck ,
308
306
) -> EvalResult < ' tcx , Align > {
309
307
let ( allocation_size, align) = self . get_size_and_align ( ptr. alloc_id ) ;
310
- ptr. check_in_alloc ( allocation_size, InboundsCheck :: MaybeDead ) ?;
308
+ ptr. check_in_alloc ( allocation_size, liveness ) ?;
311
309
Ok ( align)
312
310
}
313
311
}
0 commit comments