mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-28 09:18:53 +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..]
|
let more_lines = &line_numbers[1][1..]
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| "Invalid character after +")?;
|
.map_err(|_| "Invalid character after +")?;
|
||||||
new_range.lower + more_lines
|
new_range.lower.saturating_add(*more_lines)
|
||||||
} else if first_byte == Some(b'-') {
|
} else if first_byte == Some(b'-') {
|
||||||
// this will prevent values like "-+5" even though "+5" is valid integer
|
// this will prevent values like "-+5" even though "+5" is valid integer
|
||||||
if line_numbers[1][1..].bytes().next() == Some(b'+') {
|
if line_numbers[1][1..].bytes().next() == Some(b'+') {
|
||||||
|
Loading…
Reference in New Issue
Block a user