diff options
| -rw-r--r-- | src/librustc_mir/interpret/machine.rs | 8 |
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( |
