@@ -309,11 +309,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
309
309
pub fn check_ptr_access (
310
310
& self ,
311
311
sptr : Scalar < M :: PointerTag > ,
312
- size : Size ,
313
- align : Align ,
312
+ mem_pos : MemoryPosition ,
314
313
) -> InterpResult < ' tcx , Option < Pointer < M :: PointerTag > > > {
315
- let align = if M :: CHECK_ALIGN { Some ( align) } else { None } ;
316
- self . check_ptr_access_align ( sptr, size, align, CheckInAllocMsg :: MemoryAccessTest )
314
+ let align = if M :: CHECK_ALIGN { Some ( mem_pos . align ) } else { None } ;
315
+ self . check_ptr_access_align ( sptr, mem_pos . size , align, CheckInAllocMsg :: MemoryAccessTest )
317
316
}
318
317
319
318
/// Like `check_ptr_access`, but *definitely* checks alignment when `align`
@@ -776,7 +775,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
776
775
ptr : Scalar < M :: PointerTag > ,
777
776
size : Size ,
778
777
) -> InterpResult < ' tcx , & [ u8 ] > {
779
- let ptr = match self . check_ptr_access ( ptr, size, Align :: from_bytes ( 1 ) . unwrap ( ) ) ? {
778
+ let mem_pos = MemoryPosition :: new ( size, Align :: from_bytes ( 1 ) . unwrap ( ) ) ;
779
+ let ptr = match self . check_ptr_access ( ptr, mem_pos) ? {
780
780
Some ( ptr) => ptr,
781
781
None => return Ok ( & [ ] ) , // zero-sized access
782
782
} ;
@@ -803,7 +803,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
803
803
let src = src. into_iter ( ) ;
804
804
let size = Size :: from_bytes ( src. size_hint ( ) . 0 as u64 ) ;
805
805
// `write_bytes` checks that this lower bound matches the upper bound matches reality.
806
- let ptr = match self . check_ptr_access ( ptr, size, Align :: from_bytes ( 1 ) . unwrap ( ) ) ? {
806
+ let mem_pos = MemoryPosition :: new ( size, Align :: from_bytes ( 1 ) . unwrap ( ) ) ;
807
+ let ptr = match self . check_ptr_access ( ptr, mem_pos) ? {
807
808
Some ( ptr) => ptr,
808
809
None => return Ok ( ( ) ) , // zero-sized access
809
810
} ;
0 commit comments