From 9fcc57e4967e56b53c4cd6c436073ec45a23c148 Mon Sep 17 00:00:00 2001 From: skoriop Date: Thu, 5 Oct 2023 03:12:50 +0530 Subject: [PATCH] fix: integer overflow in `LineRange::parse_range` --- src/line_range.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/line_range.rs b/src/line_range.rs index c9094fc9..15ed3e9e 100644 --- a/src/line_range.rs +++ b/src/line_range.rs @@ -53,7 +53,7 @@ impl LineRange { let more_lines = &line_numbers[1][1..] .parse() .map_err(|_| "Invalid character after +")?; - new_range.lower + more_lines + new_range.lower.saturating_add(*more_lines) } else if first_byte == Some(b'-') { // this will prevent values like "-+5" even though "+5" is valid integer if line_numbers[1][1..].bytes().next() == Some(b'+') {