Line range minus overflow prevention

This commit is contained in:
Bojan Durdevic 2021-10-17 10:11:55 -04:00 committed by David Peter
parent 0eb4aaac1e
commit 715b0d8bf5

View file

@ -63,7 +63,7 @@ impl LineRange {
.parse()
.map_err(|_| "Invalid character after -")?;
let prev_lower = new_range.lower;
new_range.lower -= prior_lines;
new_range.lower = new_range.lower.saturating_sub(*prior_lines);
prev_lower
} else {
line_numbers[1].parse()?