Skip to content

Commit

Permalink
use memory::check_bounds_ptr for offset check
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Dec 26, 2018
1 parent d0f57c7 commit f2e14d9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,9 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
if let Scalar::Ptr(ptr) = ptr {
// Both old and new pointer must be in-bounds of a *live* allocation.
// (Of the same allocation, but that part is trivial with our representation.)
let alloc = self.memory().get(ptr.alloc_id)?;
alloc.check_bounds_ptr(ptr)?;
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live)?;
let ptr = ptr.signed_offset(offset, self)?;
alloc.check_bounds_ptr(ptr)?;
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live)?;
Ok(Scalar::Ptr(ptr))
} else {
// An integer pointer. They can only be offset by 0, and we pretend there
Expand Down

0 comments on commit f2e14d9

Please sign in to comment.