check that ptr is valid already when doing Deref, not only when doing the access
This commit is contained in:
parent
9a239ef4de
commit
3b229f1441
1 changed files with 10 additions and 1 deletions
|
|
@ -304,7 +304,16 @@ where
|
|||
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
|
||||
let val = self.read_immediate(src)?;
|
||||
trace!("deref to {} on {:?}", val.layout.ty, *val);
|
||||
self.ref_to_mplace(val)
|
||||
let mut place = self.ref_to_mplace(val)?;
|
||||
let (size, align) = self.size_and_align_of_mplace(place)?
|
||||
.unwrap_or((place.layout.size, place.layout.align.abi));
|
||||
assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?");
|
||||
place.mplace.align = align; // maximally strict checking
|
||||
// When dereferencing a pointer, it must be non-NULL, aligned, and live.
|
||||
if let Some(ptr) = self.check_mplace_access(place, Some(size))? {
|
||||
place.mplace.ptr = ptr.into();
|
||||
}
|
||||
Ok(place)
|
||||
}
|
||||
|
||||
/// Check if the given place is good for memory access with the given
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue