mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-27 16:58:50 +01:00
fix: integer overflow in LineRange::parse_range
This commit is contained in:
parent
8e35a56712
commit
9fcc57e496
@ -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'+') {
|
||||
|
Loading…
Reference in New Issue
Block a user