about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Poveda <christianpoveda@protonmail.com>2019-06-16 03:48:40 -0500
committerChristian Poveda <christianpoveda@protonmail.com>2019-06-16 03:49:13 -0500
commit1e388703c07c6f693d5974b9f8520403a4fc57c0 (patch)
treef94668e3aa55501eca3f9de3960c9dce0524b49f
parentc5c06a5f62c2cb6f19da84d992cb1bb92784b537 (diff)
downloadrust-1e388703c07c6f693d5974b9f8520403a4fc57c0.tar.gz
rust-1e388703c07c6f693d5974b9f8520403a4fc57c0.zip
Add special behaviour when int is zero
-rw-r--r--src/librustc_mir/interpret/machine.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs
index 8eb891cf90a..2581c134b26 100644
--- a/src/librustc_mir/interpret/machine.rs
+++ b/src/librustc_mir/interpret/machine.rs
@@ -211,10 +211,14 @@ pub trait Machine<'mir, 'tcx>: Sized {
     ) -> InterpResult<'tcx>;
 
     fn int_to_ptr(
-        _int: u64,
+        int: u64,
         _extra: &Self::MemoryExtra,
     ) -> InterpResult<'tcx, Pointer<Self::PointerTag>> {
-        Err(InterpErrorInfo::from(InterpError::ReadBytesAsPointer))
+        if int == 0 {
+            Err(InterpErrorInfo::from(InterpError::InvalidNullPointerUsage))
+        } else {
+            Err(InterpErrorInfo::from(InterpError::ReadBytesAsPointer))
+        }
     }
 
     fn ptr_to_int(