diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 8eb891cf90a09..2581c134b2662 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> { - Err(InterpErrorInfo::from(InterpError::ReadBytesAsPointer)) + if int == 0 { + Err(InterpErrorInfo::from(InterpError::InvalidNullPointerUsage)) + } else { + Err(InterpErrorInfo::from(InterpError::ReadBytesAsPointer)) + } } fn ptr_to_int(