Skip to content

Commit 5acadca

Browse files
committed
Directly write to dest place in EvalContextExt::Write
1 parent 7567e5b commit 5acadca

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
@@ -628,14 +628,18 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
628628
let Ok(offset) = u64::try_from(offset) else {
629629
let einval = this.eval_libc("EINVAL");
630630
this.set_last_error(einval)?;
631-
return Ok(Scalar::from_target_isize(-1, this));
631+
let res = Scalar::from_target_isize(-1, this);
632+
this.write_scalar(res, dest)?;
633+
return Ok(());
632634
};
633635
fd.pwrite(communicate, &bytes, offset, this)
634636
}
635637
};
636638

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

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

0 commit comments

Comments
 (0)