Rollup merge of #87447 - RalfJung:not-null, r=oli-obk
Miri: santiy check that null pointer can never have an AllocId
This commit is contained in:
commit
fc0b4848cb
1 changed files with 5 additions and 1 deletions
|
@ -1142,7 +1142,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||
Err(ptr) => ptr.into(),
|
||||
Ok(bits) => {
|
||||
let addr = u64::try_from(bits).unwrap();
|
||||
M::ptr_from_addr(&self, addr)
|
||||
let ptr = M::ptr_from_addr(&self, addr);
|
||||
if addr == 0 {
|
||||
assert!(ptr.provenance.is_none(), "null pointer can never have an AllocId");
|
||||
}
|
||||
ptr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue