@@ -20,7 +20,7 @@ use syntax::ast::Mutability;
20
20
use super :: {
21
21
Pointer , AllocId , Allocation , GlobalId , AllocationExtra ,
22
22
EvalResult , Scalar , InterpError , AllocKind , PointerArithmetic ,
23
- Machine , AllocMap , MayLeak , ErrorHandled , CheckInAllocMsg ,
23
+ Machine , AllocMap , MayLeak , ErrorHandled , CheckInAllocMsg , InboundsCheck ,
24
24
} ;
25
25
26
26
#[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash ) ]
@@ -252,7 +252,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
252
252
Scalar :: Ptr ( ptr) => {
253
253
// check this is not NULL -- which we can ensure only if this is in-bounds
254
254
// of some (potentially dead) allocation.
255
- let align = self . check_bounds_ptr ( ptr, CheckInAllocMsg :: NullPointer ) ?;
255
+ let align = self . check_bounds_ptr ( ptr, InboundsCheck :: MaybeDead , CheckInAllocMsg :: NullPointer ) ?;
256
256
( ptr. offset . bytes ( ) , align)
257
257
}
258
258
Scalar :: Bits { bits, size } => {
@@ -292,9 +292,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
292
292
pub fn check_bounds_ptr (
293
293
& self ,
294
294
ptr : Pointer < M :: PointerTag > ,
295
+ liveness : InboundsCheck ,
295
296
msg : CheckInAllocMsg ,
296
297
) -> EvalResult < ' tcx , Align > {
297
- let ( allocation_size, align) = self . get_size_and_align ( ptr. alloc_id , msg ) ?;
298
+ let ( allocation_size, align) = self . get_size_and_align ( ptr. alloc_id , liveness ) ?;
298
299
ptr. check_in_alloc ( allocation_size, msg) ?;
299
300
Ok ( align)
300
301
}
@@ -419,11 +420,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
419
420
420
421
/// Obtain the size and alignment of an allocation, even if that allocation has been deallocated
421
422
///
422
- /// If `liveness` is `InboundsCheck::Dead `, this function always returns `Ok`
423
+ /// If `liveness` is `InboundsCheck::MaybeDead `, this function always returns `Ok`
423
424
pub fn get_size_and_align (
424
425
& self ,
425
426
id : AllocId ,
426
- msg : CheckInAllocMsg ,
427
+ liveness : InboundsCheck ,
427
428
) -> EvalResult < ' static , ( Size , Align ) > {
428
429
if let Ok ( alloc) = self . get ( id) {
429
430
return Ok ( ( Size :: from_bytes ( alloc. bytes . len ( ) as u64 ) , alloc. align ) ) ;
@@ -439,8 +440,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
439
440
let layout = self . tcx . layout_of ( ParamEnv :: empty ( ) . and ( ty) ) . unwrap ( ) ;
440
441
Ok ( ( layout. size , layout. align . abi ) )
441
442
}
442
- _ => match msg {
443
- CheckInAllocMsg :: NullPointer | CheckInAllocMsg :: OutOfBounds => {
443
+ _ => match liveness {
444
+ InboundsCheck :: MaybeDead => {
444
445
// Must be a deallocated pointer
445
446
Ok ( * self . dead_alloc_map . get ( & id) . expect (
446
447
"allocation missing in dead_alloc_map"
0 commit comments