@@ -506,13 +506,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
506506 fn write_os_str_to_target_str (
507507 & mut self ,
508508 os_str : & OsStr ,
509- scalar : Scalar < Tag > ,
509+ mplace : MPlaceTy < ' tcx , Tag > ,
510510 size : u64 ,
511511 ) -> InterpResult < ' tcx , ( bool , u64 ) > {
512512 if cfg ! ( target_os = "unix" ) {
513- self . write_os_str_to_c_str ( os_str, scalar , size)
513+ self . write_os_str_to_c_str ( os_str, mplace . ptr , size)
514514 } else if cfg ! ( target_os = "windows" ) {
515- self . write_os_str_to_wide_str ( os_str, scalar , size)
515+ self . write_os_str_to_wide_str ( os_str, mplace , size)
516516 } else {
517517 panic ! ( "support for target OS not yet available" )
518518 }
@@ -565,7 +565,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
565565 fn write_os_str_to_wide_str (
566566 & mut self ,
567567 os_str : & OsStr ,
568- scalar : Scalar < Tag > ,
568+ mplace : MPlaceTy < ' tcx , Tag > ,
569569 size : u64 ,
570570 ) -> InterpResult < ' tcx , ( bool , u64 ) > {
571571 #[ cfg( target_os = "windows" ) ]
@@ -578,32 +578,29 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
578578 }
579579
580580 let u16_vec = os_str_to_u16vec ( os_str) ;
581- // If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required null
582- // terminator to memory using the `ptr` pointer would cause an out-of-bounds access.
581+ // If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required
582+ // 0x0000 terminator to memory would cause an out-of-bounds access.
583583 let string_length = u16_vec. len ( ) as u64 ;
584584 if size <= string_length {
585585 return Ok ( ( false , string_length) ) ;
586586 }
587587
588588 let this = self . eval_context_mut ( ) ;
589589
590- // Store the UTF-16 string. We just allocated so we know the bounds are fine.
590+ // Store the UTF-16 string.
591591 let char_size = Size :: from_bytes ( 2 ) ;
592- let place_ptr = scalar. assert_ptr ( ) ;
593- /*
594592 for ( idx, & c) in u16_vec. iter ( ) . enumerate ( ) {
595- let place = this.mplace_field(place , idx as u64)?;
593+ let place = this. mplace_field ( mplace , idx as u64 ) ?;
596594 this. write_scalar ( Scalar :: from_uint ( c, char_size) , place. into ( ) ) ?;
597595 }
598- */
599596 Ok ( ( true , string_length) )
600597 }
601598
602599 fn alloc_os_str_as_target_str (
603600 & mut self ,
604601 os_str : & OsStr ,
605602 memkind : MemoryKind < MiriMemoryKind > ,
606- ) -> Pointer < Tag > {
603+ ) -> MPlaceTy < ' tcx , Tag > {
607604 if cfg ! ( target_os = "unix" ) {
608605 self . alloc_os_str_as_c_str ( os_str, memkind)
609606 } else if cfg ! ( target_os = "windows" ) {
@@ -617,28 +614,28 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
617614 & mut self ,
618615 os_str : & OsStr ,
619616 memkind : MemoryKind < MiriMemoryKind > ,
620- ) -> Pointer < Tag > {
617+ ) -> MPlaceTy < ' tcx , Tag > {
621618 let size = os_str. len ( ) as u64 + 1 ; // Make space for `0` terminator.
622619 let this = self . eval_context_mut ( ) ;
623620
624621 let arg_type = this. tcx . mk_array ( this. tcx . types . u8 , size) ;
625622 let arg_place = this. allocate ( this. layout_of ( arg_type) . unwrap ( ) , memkind) ;
626623 self . write_os_str_to_c_str ( os_str, arg_place. ptr , size) . unwrap ( ) ;
627- arg_place. ptr . assert_ptr ( )
624+ arg_place
628625 }
629626
630627 fn alloc_os_str_as_wide_str (
631628 & mut self ,
632629 os_str : & OsStr ,
633630 memkind : MemoryKind < MiriMemoryKind > ,
634- ) -> Pointer < Tag > {
631+ ) -> MPlaceTy < ' tcx , Tag > {
635632 let size = os_str. len ( ) as u64 + 1 ; // Make space for `0x0000` terminator.
636633 let this = self . eval_context_mut ( ) ;
637634
638635 let arg_type = this. tcx . mk_array ( this. tcx . types . u16 , size) ;
639636 let arg_place = this. allocate ( this. layout_of ( arg_type) . unwrap ( ) , memkind) ;
640- self . write_os_str_to_wide_str ( os_str, arg_place. ptr , size) . unwrap ( ) ;
641- arg_place. ptr . assert_ptr ( )
637+ self . write_os_str_to_wide_str ( os_str, arg_place, size) . unwrap ( ) ;
638+ arg_place
642639 }
643640}
644641
0 commit comments