From b07f8be4bbb2b074dadf15aa03f819b3a26db0a5 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 20 Oct 2020 10:14:03 -0700 Subject: [PATCH] use checked addition with range --- src/bytes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, };