Skip to content

Commit f386329

Browse files
committed
intptrcast: only find strictly in-bounds pointers when we are not hitting the base address
1 parent 5d62040 commit f386329

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/tools/miri/src/intptrcast.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ impl<'mir, 'tcx> GlobalStateInner {
8282
let (glb, alloc_id) = global_state.int_to_ptr_map[pos - 1];
8383
// This never overflows because `addr >= glb`
8484
let offset = addr - glb;
85-
// If the offset exceeds the size of the allocation, don't use this `alloc_id`.
85+
// We require this to be strict in-bounds of the allocation. This arm is only
86+
// entered for addresses that are not the base address, so even zero-sized
87+
// allocations will get recognized at their base address -- but all other
88+
// allocations will *not* be recognized at their "end" address.
8689
let size = ecx.get_alloc_info(alloc_id).0;
87-
if offset <= size.bytes() { Some(alloc_id) } else { None }
90+
if offset < size.bytes() { Some(alloc_id) } else { None }
8891
}
8992
}?;
9093

0 commit comments

Comments
 (0)