Skip to content

Commit e3b4f8e

Browse files
committed
better error message when using NULL in to_ptr
1 parent 0b8c691 commit e3b4f8e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustc/mir/interpret/value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ impl<'tcx> Scalar {
148148

149149
pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> {
150150
match self {
151-
Scalar::Bits {..} => err!(ReadBytesAsPointer),
151+
Scalar::Bits { bits: 0, .. } => err!(InvalidNullPointerUsage),
152+
Scalar::Bits { .. } => err!(ReadBytesAsPointer),
152153
Scalar::Ptr(p) => Ok(p),
153154
}
154155
}

0 commit comments

Comments
 (0)