Miri: santiy check that null pointer can never have an AllocId

This commit is contained in:
Ralf Jung 2021-07-25 11:31:57 +02:00
parent 1c66d11a34
commit f4861f3251

View file

@ -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
}
}
}