@@ -582,8 +582,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
582582 fd. pread ( communicate, & mut bytes, offset, this)
583583 }
584584 } ;
585- let res = read_byte_helper ( buf, bytes, result, this) ?;
586- this. write_scalar ( res, dest) ?;
585+ read_byte_helper ( buf, bytes, result, dest, this) ?;
587586 Ok ( ( ) )
588587 }
589588
@@ -625,8 +624,9 @@ fn read_byte_helper<'tcx>(
625624 buf : Pointer ,
626625 bytes : Vec < u8 > ,
627626 result : InterpResult < ' tcx , io:: Result < usize > > ,
627+ dest : & MPlaceTy < ' tcx > ,
628628 ecx : & mut MiriInterpCx < ' tcx > ,
629- ) -> InterpResult < ' tcx , Scalar > {
629+ ) -> InterpResult < ' tcx > {
630630 // `File::read` never returns a value larger than `count`, so this cannot fail.
631631 match result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) {
632632 // try to pass this the write_ptr inside write
@@ -639,11 +639,13 @@ fn read_byte_helper<'tcx>(
639639 buf,
640640 bytes[ ..usize:: try_from ( read_bytes) . unwrap ( ) ] . iter ( ) . copied ( ) ,
641641 ) ?;
642- Ok ( Scalar :: from_target_isize ( read_bytes, ecx) )
642+ ecx. write_scalar ( Scalar :: from_target_isize ( read_bytes, ecx) , dest) ?;
643+ return Ok ( ( ) ) ;
643644 }
644645 Err ( e) => {
645646 ecx. set_last_error_from_io_error ( e) ?;
646- Ok ( Scalar :: from_target_isize ( -1 , ecx) )
647+ ecx. write_scalar ( Scalar :: from_target_isize ( -1 , ecx) , dest) ?;
648+ return Ok ( ( ) ) ;
647649 }
648650 }
649651}
0 commit comments