Rollup merge of #97216 - RalfJung:null-ptr-check, r=oli-obk
Ensure we never consider the null pointer dereferencable This replaces the checks that are being removed in https://github.com/rust-lang/rust/pull/97188. Those checks were too early and hence incorrect.
This commit is contained in:
commit
2ab919ad9c
1 changed files with 4 additions and 0 deletions
|
@ -441,6 +441,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
msg,
|
msg,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// Ensure we never consider the null pointer dereferencable.
|
||||||
|
if M::PointerTag::OFFSET_IS_ADDR {
|
||||||
|
assert_ne!(ptr.addr(), Size::ZERO);
|
||||||
|
}
|
||||||
// Test align. Check this last; if both bounds and alignment are violated
|
// Test align. Check this last; if both bounds and alignment are violated
|
||||||
// we want the error to be about the bounds.
|
// we want the error to be about the bounds.
|
||||||
if let Some(align) = align {
|
if let Some(align) = align {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue