about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-05-20 15:55:55 +0200
committerRalf Jung <post@ralfj.de>2022-05-20 15:55:55 +0200
commit0b781b04cb1168095807f86e3b0dfadebf3a1ed2 (patch)
tree7d01396d86601056d95b39a2a731c56c4cfae603 /compiler/rustc_const_eval/src/interpret
parent512a328e2fb32bddd206461770a2c058368519cc (diff)
downloadrust-0b781b04cb1168095807f86e3b0dfadebf3a1ed2.tar.gz
rust-0b781b04cb1168095807f86e3b0dfadebf3a1ed2.zip
Ensure we never consider the null pointer dereferencable
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
-rw-r--r--compiler/rustc_const_eval/src/interpret/memory.rs4
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 {