diff options
author | Ralf Jung <post@ralfj.de> | 2022-05-20 15:55:55 +0200 |
---|---|---|
committer | Ralf Jung <post@ralfj.de> | 2022-05-20 15:55:55 +0200 |
commit | 0b781b04cb1168095807f86e3b0dfadebf3a1ed2 (patch) | |
tree | 7d01396d86601056d95b39a2a731c56c4cfae603 | |
parent | 512a328e2fb32bddd206461770a2c058368519cc (diff) | |
download | rust-0b781b04cb1168095807f86e3b0dfadebf3a1ed2.tar.gz |
Ensure we never consider the null pointer dereferencable
-rw-r--r-- | compiler/rustc_const_eval/src/interpret/memory.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 33162a01ed2..5dcd209a8fb 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -441,6 +441,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { 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 // we want the error to be about the bounds. if let Some(align) = align { |