diff --git a/src/bytes.rs b/src/bytes.rs index 96af7d6af..66b941d99 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -237,7 +237,7 @@ impl Bytes { }; let end = match range.end_bound() { - Bound::Included(&n) => n + 1, + Bound::Included(&n) => n.checked_add(1).expect("out of range"), Bound::Excluded(&n) => n, Bound::Unbounded => len, };