Miri: santiy check that null pointer can never have an AllocId
This commit is contained in:
parent
1c66d11a34
commit
f4861f3251
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(),
|
Err(ptr) => ptr.into(),
|
||||||
Ok(bits) => {
|
Ok(bits) => {
|
||||||
let addr = u64::try_from(bits).unwrap();
|
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
Add a link
Reference in a new issue