Auto merge of #115608 - RalfJung:fn-arg-validity, r=oli-obk
miri: catch function calls where the argument is caller-invalid / the return value callee-invalid When doing a type-changing copy, we must validate the data both at the old and new type. Fixes https://github.com/rust-lang/miri/issues/3017
This commit is contained in:
commit
3d249706aa
9 changed files with 108 additions and 4 deletions
|
@ -796,6 +796,13 @@ where
|
|||
dest: &impl Writeable<'tcx, M::Provenance>,
|
||||
allow_transmute: bool,
|
||||
) -> InterpResult<'tcx> {
|
||||
// Generally for transmutation, data must be valid both at the old and new type.
|
||||
// But if the types are the same, the 2nd validation below suffices.
|
||||
if src.layout().ty != dest.layout().ty && M::enforce_validity(self, src.layout()) {
|
||||
self.validate_operand(&src.to_op(self)?)?;
|
||||
}
|
||||
|
||||
// Do the actual copy.
|
||||
self.copy_op_no_validate(src, dest, allow_transmute)?;
|
||||
|
||||
if M::enforce_validity(self, dest.layout()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue