@@ -622,8 +622,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
622
622
this. write_scalar ( Scalar :: from_target_isize ( res, this) , dest) ?;
623
623
return Ok ( ( ) ) ;
624
624
} ;
625
- let res = write_byte_helper ( offset, fd, bytes, communicate, this) ?;
626
- this. write_scalar ( res, dest) ?;
625
+ write_byte_helper ( offset, fd, bytes, communicate, dest, this) ?;
627
626
Ok ( ( ) )
628
627
}
629
628
@@ -666,20 +665,25 @@ fn write_byte_helper<'tcx>(
666
665
fd : FileDescriptionRef ,
667
666
bytes : Vec < u8 > ,
668
667
communicate : bool ,
668
+ dest : & MPlaceTy < ' tcx > ,
669
669
ecx : & mut MiriInterpCx < ' tcx > ,
670
- ) -> InterpResult < ' tcx , Scalar > {
670
+ ) -> InterpResult < ' tcx > {
671
671
let result = match offset {
672
672
None => fd. write ( & fd, communicate, & bytes, ecx) ,
673
673
Some ( offset) => {
674
674
let Ok ( offset) = u64:: try_from ( offset) else {
675
675
let einval = ecx. eval_libc ( "EINVAL" ) ;
676
676
ecx. set_last_error ( einval) ?;
677
- return Ok ( Scalar :: from_target_isize ( -1 , ecx) ) ;
677
+ let res = Scalar :: from_target_isize ( -1 , ecx) ;
678
+ ecx. write_scalar ( res, dest) ?;
679
+ return Ok ( ( ) ) ;
678
680
} ;
679
681
fd. pwrite ( communicate, & bytes, offset, ecx)
680
682
}
681
683
} ;
684
+ // Write the result to the dest place.
682
685
let result = result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
683
- let res = ecx. try_unwrap_io_result ( result) ?;
684
- Ok ( Scalar :: from_target_isize ( res, ecx) )
686
+ let res = Scalar :: from_target_isize ( ecx. try_unwrap_io_result ( result) ?, ecx) ;
687
+ ecx. write_scalar ( res, dest) ?;
688
+ return Ok ( ( ) ) ;
685
689
}
0 commit comments