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