Skip to content

Commit

Permalink
use Size addition instead of checked int addition
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 25, 2020
1 parent 0bc108a commit afcb634
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/allocation.rs
Expand Up @@ -293,7 +293,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
let offset = usize::try_from(ptr.offset.bytes()).unwrap();
Ok(match self.bytes[offset..].iter().position(|&c| c == 0) {
Some(size) => {
let size_with_null = Size::from_bytes(size.checked_add(1).unwrap());
let size_with_null = Size::add(Size::from_bytes(size), Size::from_bytes(1));
// Go through `get_bytes` for checks and AllocationExtra hooks.
// We read the null, so we include it in the request, but we want it removed
// from the result, so we do subslicing.
Expand Down

0 comments on commit afcb634

Please sign in to comment.