From 879d8f707056530b4b3054a3c089f9c21a72ee46 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 24 May 2018 11:12:33 +0200 Subject: [PATCH] Properly check defined bits range --- src/librustc_mir/interpret/memory.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 42e93593028..4305d6dd7c5 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -233,7 +233,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { (ptr.offset.bytes(), alloc.align) } Scalar::Bits { bits, defined } => { - if defined <= self.pointer_size().bits() as u8 { + if (defined as u64) < self.pointer_size().bits() { return err!(ReadUndefBytes); } // FIXME: what on earth does this line do? docs or fix needed! @@ -750,7 +750,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { val.offset.bytes() as u128 } - Scalar::Bits { bits, defined } if defined >= size.bits() as u8 && defined != 0 => bits, + Scalar::Bits { bits, defined } if defined as u64 >= size.bits() && size.bits() != 0 => bits, Scalar::Bits { .. } => { self.check_align(ptr.into(), ptr_align)?;