@@ -309,11 +309,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
309309 pub fn check_ptr_access (
310310 & self ,
311311 sptr : Scalar < M :: PointerTag > ,
312- size : Size ,
313- align : Align ,
312+ mem_pos : MemoryPosition ,
314313 ) -> 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 )
317316 }
318317
319318 /// 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> {
776775 ptr : Scalar < M :: PointerTag > ,
777776 size : Size ,
778777 ) -> 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) ? {
780780 Some ( ptr) => ptr,
781781 None => return Ok ( & [ ] ) , // zero-sized access
782782 } ;
@@ -803,7 +803,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
803803 let src = src. into_iter ( ) ;
804804 let size = Size :: from_bytes ( src. size_hint ( ) . 0 as u64 ) ;
805805 // `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) ? {
807808 Some ( ptr) => ptr,
808809 None => return Ok ( ( ) ) , // zero-sized access
809810 } ;
0 commit comments