Add special behaviour when int is zero

This commit is contained in:
Christian Poveda 2019-06-16 03:48:40 -05:00
parent c5c06a5f62
commit 1e388703c0

View file

@ -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(