Skip to content

Commit 9631ad8

Browse files
committed
Directly write to dest place in EvalContextExt::Write
1 parent 5d04e07 commit 9631ad8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/shims/unix/fd.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,14 +629,18 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
629629
let Ok(offset) = u64::try_from(offset) else {
630630
let einval = this.eval_libc("EINVAL");
631631
this.set_last_error(einval)?;
632-
return Ok(Scalar::from_target_isize(-1, this));
632+
let res = Scalar::from_target_isize(-1, this);
633+
this.write_scalar(res, dest)?;
634+
return Ok(());
633635
};
634636
fd.pwrite(communicate, &bytes, offset, this)
635637
}
636638
};
637639

638-
let result = result?.map(|c| i64::try_from(c).unwrap());
639-
Ok(Scalar::from_target_isize(this.try_unwrap_io_result(result)?, this))
640+
let result = this.try_unwrap_io_result(result?.map(|c| i64::try_from(c).unwrap()))?;
641+
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
642+
Ok(())
643+
//Ok(Scalar::from_target_isize(this.try_unwrap_io_result(result)?, this))
640644
}
641645

642646
/// This function write bytes to the user supplied buffer and write the total number of bytes

0 commit comments

Comments
 (0)