Skip to content

Commit

Permalink
Add special behaviour when int is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Jun 16, 2019
1 parent c5c06a5 commit 1e38870
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 1e38870

Please sign in to comment.