Skip to content

Commit

Permalink
fix: out-of-bounds panic when diffing a large number of words
Browse files Browse the repository at this point in the history
Fixes Wilfred#688, fixes Wilfred#694 and fixes Wilfred#682.
  • Loading branch information
JonathanxD committed Apr 5, 2024
1 parent db281c6 commit dffa37c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/line_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub(crate) fn change_positions(lhs_src: &str, rhs_src: &str) -> Vec<MatchedPos>
// have a very large number of words, don't diff
// individual words.
if lhs_words.len() > MAX_WORDS_IN_LINE || rhs_words.len() > MAX_WORDS_IN_LINE {
for lhs_pos in lhs_lp.from_region(lhs_offset, lhs_offset + lhs_part.len()) {
for lhs_pos in lhs_lp.from_region(lhs_offset, lhs_offset + line_len_in_bytes(&lhs_part)) {
mps.push(MatchedPos {
kind: MatchKind::NovelWord {
highlight: TokenKind::Atom(AtomKind::Normal),
Expand Down

0 comments on commit dffa37c

Please sign in to comment.