Skip to content

Commit

Permalink
Merge pull request #589 from RalfJung/check-bounds
Browse files Browse the repository at this point in the history
use memory::check_bounds_ptr for offset check
  • Loading branch information
oli-obk authored Dec 26, 2018
2 parents d0f57c7 + f2e14d9 commit 6c2fc6d
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 6c2fc6d

Please sign in to comment.