Skip to content

Commit 0b781b0

Browse files
committed
Ensure we never consider the null pointer dereferencable
1 parent 512a328 commit 0b781b0

File tree

1 file changed

+4
-0
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+4
-0
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+4
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
441441
msg,
442442
})
443443
}
444+
// Ensure we never consider the null pointer dereferencable.
445+
if M::PointerTag::OFFSET_IS_ADDR {
446+
assert_ne!(ptr.addr(), Size::ZERO);
447+
}
444448
// Test align. Check this last; if both bounds and alignment are violated
445449
// we want the error to be about the bounds.
446450
if let Some(align) = align {

0 commit comments

Comments
 (0)