@@ -20,7 +20,7 @@ use syntax::ast::Mutability;
2020use super :: {
2121 Pointer , AllocId , Allocation , GlobalId , AllocationExtra ,
2222 EvalResult , Scalar , InterpError , AllocKind , PointerArithmetic ,
23- Machine , AllocMap , MayLeak , ErrorHandled , CheckInAllocMsg ,
23+ Machine , AllocMap , MayLeak , ErrorHandled , CheckInAllocMsg , InboundsCheck ,
2424} ;
2525
2626#[ 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> {
252252 Scalar :: Ptr ( ptr) => {
253253 // check this is not NULL -- which we can ensure only if this is in-bounds
254254 // 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 ) ?;
256256 ( ptr. offset . bytes ( ) , align)
257257 }
258258 Scalar :: Bits { bits, size } => {
@@ -292,9 +292,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
292292 pub fn check_bounds_ptr (
293293 & self ,
294294 ptr : Pointer < M :: PointerTag > ,
295+ liveness : InboundsCheck ,
295296 msg : CheckInAllocMsg ,
296297 ) -> 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 ) ?;
298299 ptr. check_in_alloc ( allocation_size, msg) ?;
299300 Ok ( align)
300301 }
@@ -419,11 +420,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
419420
420421 /// Obtain the size and alignment of an allocation, even if that allocation has been deallocated
421422 ///
422- /// If `liveness` is `InboundsCheck::Dead `, this function always returns `Ok`
423+ /// If `liveness` is `InboundsCheck::MaybeDead `, this function always returns `Ok`
423424 pub fn get_size_and_align (
424425 & self ,
425426 id : AllocId ,
426- msg : CheckInAllocMsg ,
427+ liveness : InboundsCheck ,
427428 ) -> EvalResult < ' static , ( Size , Align ) > {
428429 if let Ok ( alloc) = self . get ( id) {
429430 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> {
439440 let layout = self . tcx . layout_of ( ParamEnv :: empty ( ) . and ( ty) ) . unwrap ( ) ;
440441 Ok ( ( layout. size , layout. align . abi ) )
441442 }
442- _ => match msg {
443- CheckInAllocMsg :: NullPointer | CheckInAllocMsg :: OutOfBounds => {
443+ _ => match liveness {
444+ InboundsCheck :: MaybeDead => {
444445 // Must be a deallocated pointer
445446 Ok ( * self . dead_alloc_map . get ( & id) . expect (
446447 "allocation missing in dead_alloc_map"
0 commit comments