@@ -506,13 +506,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
506
506
fn write_os_str_to_target_str (
507
507
& mut self ,
508
508
os_str : & OsStr ,
509
- scalar : Scalar < Tag > ,
509
+ mplace : MPlaceTy < ' tcx , Tag > ,
510
510
size : u64 ,
511
511
) -> InterpResult < ' tcx , ( bool , u64 ) > {
512
512
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)
514
514
} 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)
516
516
} else {
517
517
panic ! ( "support for target OS not yet available" )
518
518
}
@@ -565,7 +565,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
565
565
fn write_os_str_to_wide_str (
566
566
& mut self ,
567
567
os_str : & OsStr ,
568
- scalar : Scalar < Tag > ,
568
+ mplace : MPlaceTy < ' tcx , Tag > ,
569
569
size : u64 ,
570
570
) -> InterpResult < ' tcx , ( bool , u64 ) > {
571
571
#[ cfg( target_os = "windows" ) ]
@@ -578,32 +578,29 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
578
578
}
579
579
580
580
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.
583
583
let string_length = u16_vec. len ( ) as u64 ;
584
584
if size <= string_length {
585
585
return Ok ( ( false , string_length) ) ;
586
586
}
587
587
588
588
let this = self . eval_context_mut ( ) ;
589
589
590
- // Store the UTF-16 string. We just allocated so we know the bounds are fine.
590
+ // Store the UTF-16 string.
591
591
let char_size = Size :: from_bytes ( 2 ) ;
592
- let place_ptr = scalar. assert_ptr ( ) ;
593
- /*
594
592
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 ) ?;
596
594
this. write_scalar ( Scalar :: from_uint ( c, char_size) , place. into ( ) ) ?;
597
595
}
598
- */
599
596
Ok ( ( true , string_length) )
600
597
}
601
598
602
599
fn alloc_os_str_as_target_str (
603
600
& mut self ,
604
601
os_str : & OsStr ,
605
602
memkind : MemoryKind < MiriMemoryKind > ,
606
- ) -> Pointer < Tag > {
603
+ ) -> MPlaceTy < ' tcx , Tag > {
607
604
if cfg ! ( target_os = "unix" ) {
608
605
self . alloc_os_str_as_c_str ( os_str, memkind)
609
606
} else if cfg ! ( target_os = "windows" ) {
@@ -617,28 +614,28 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
617
614
& mut self ,
618
615
os_str : & OsStr ,
619
616
memkind : MemoryKind < MiriMemoryKind > ,
620
- ) -> Pointer < Tag > {
617
+ ) -> MPlaceTy < ' tcx , Tag > {
621
618
let size = os_str. len ( ) as u64 + 1 ; // Make space for `0` terminator.
622
619
let this = self . eval_context_mut ( ) ;
623
620
624
621
let arg_type = this. tcx . mk_array ( this. tcx . types . u8 , size) ;
625
622
let arg_place = this. allocate ( this. layout_of ( arg_type) . unwrap ( ) , memkind) ;
626
623
self . write_os_str_to_c_str ( os_str, arg_place. ptr , size) . unwrap ( ) ;
627
- arg_place. ptr . assert_ptr ( )
624
+ arg_place
628
625
}
629
626
630
627
fn alloc_os_str_as_wide_str (
631
628
& mut self ,
632
629
os_str : & OsStr ,
633
630
memkind : MemoryKind < MiriMemoryKind > ,
634
- ) -> Pointer < Tag > {
631
+ ) -> MPlaceTy < ' tcx , Tag > {
635
632
let size = os_str. len ( ) as u64 + 1 ; // Make space for `0x0000` terminator.
636
633
let this = self . eval_context_mut ( ) ;
637
634
638
635
let arg_type = this. tcx . mk_array ( this. tcx . types . u16 , size) ;
639
636
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
642
639
}
643
640
}
644
641
0 commit comments