@@ -697,27 +697,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
697697 ) -> InterpResult < ' tcx , MPlaceTy < ' tcx , Provenance > > {
698698 let this = self . eval_context_ref ( ) ;
699699 let ptr = this. read_pointer ( op) ?;
700-
701- let mplace = MPlaceTy :: from_aligned_ptr ( ptr, layout) ;
702-
703- this. check_mplace ( & mplace) ?;
704-
705- Ok ( mplace)
706- }
707-
708- /// Deref' a pointer *without* checking that the place is dereferenceable.
709- fn deref_pointer_unchecked (
710- & self ,
711- val : & ImmTy < ' tcx , Provenance > ,
712- layout : TyAndLayout < ' tcx > ,
713- ) -> InterpResult < ' tcx , MPlaceTy < ' tcx , Provenance > > {
714- let this = self . eval_context_ref ( ) ;
715- let mut mplace = this. ref_to_mplace ( val) ?;
716-
717- mplace. layout = layout;
718- mplace. align = layout. align . abi ;
719-
720- Ok ( mplace)
700+ Ok ( this. ptr_to_mplace ( ptr, layout) )
721701 }
722702
723703 /// Calculates the MPlaceTy given the offset and layout of an access on an operand
@@ -805,7 +785,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
805785 loop {
806786 // FIXME: We are re-getting the allocation each time around the loop.
807787 // Would be nice if we could somehow "extend" an existing AllocRange.
808- let alloc = this. get_ptr_alloc ( ptr. offset ( len, this) ?, size1, Align :: ONE ) ?. unwrap ( ) ; // not a ZST, so we will get a result
788+ let alloc = this. get_ptr_alloc ( ptr. offset ( len, this) ?, size1) ?. unwrap ( ) ; // not a ZST, so we will get a result
809789 let byte = alloc. read_integer ( alloc_range ( Size :: ZERO , size1) ) ?. to_u8 ( ) ?;
810790 if byte == 0 {
811791 break ;
@@ -845,13 +825,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
845825 fn read_wide_str ( & self , mut ptr : Pointer < Option < Provenance > > ) -> InterpResult < ' tcx , Vec < u16 > > {
846826 let this = self . eval_context_ref ( ) ;
847827 let size2 = Size :: from_bytes ( 2 ) ;
848- let align2 = Align :: from_bytes ( 2 ) . unwrap ( ) ;
828+ this . check_ptr_align ( ptr , Align :: from_bytes ( 2 ) . unwrap ( ) ) ? ;
849829
850830 let mut wchars = Vec :: new ( ) ;
851831 loop {
852832 // FIXME: We are re-getting the allocation each time around the loop.
853833 // Would be nice if we could somehow "extend" an existing AllocRange.
854- let alloc = this. get_ptr_alloc ( ptr, size2, align2 ) ?. unwrap ( ) ; // not a ZST, so we will get a result
834+ let alloc = this. get_ptr_alloc ( ptr, size2) ?. unwrap ( ) ; // not a ZST, so we will get a result
855835 let wchar = alloc. read_integer ( alloc_range ( Size :: ZERO , size2) ) ?. to_u16 ( ) ?;
856836 if wchar == 0 {
857837 break ;
@@ -887,9 +867,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
887867 // Store the UTF-16 string.
888868 let size2 = Size :: from_bytes ( 2 ) ;
889869 let this = self . eval_context_mut ( ) ;
890- let mut alloc = this
891- . get_ptr_alloc_mut ( ptr, size2 * string_length, Align :: from_bytes ( 2 ) . unwrap ( ) ) ?
892- . unwrap ( ) ; // not a ZST, so we will get a result
870+ this. check_ptr_align ( ptr, Align :: from_bytes ( 2 ) . unwrap ( ) ) ?;
871+ let mut alloc = this. get_ptr_alloc_mut ( ptr, size2 * string_length) ?. unwrap ( ) ; // not a ZST, so we will get a result
893872 for ( offset, wchar) in wide_str. iter ( ) . copied ( ) . chain ( iter:: once ( 0x0000 ) ) . enumerate ( ) {
894873 let offset = u64:: try_from ( offset) . unwrap ( ) ;
895874 alloc. write_scalar ( alloc_range ( size2 * offset, size2) , Scalar :: from_u16 ( wchar) ) ?;
0 commit comments