Skip to content

Commit

Permalink
Don't ignore the start offset when searching for an anchored literal.
Browse files Browse the repository at this point in the history
If we ignore the start offset, then we may report a match where none
exists. This can in particular lead to a match loop that never terminates.

Fixes #255.
  • Loading branch information
BurntSushi committed Jul 9, 2016
1 parent cf04879 commit cd85664
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,11 @@ impl<'c> ExecNoSync<'c> {
lits.find_start(&text[start..])
.map(|(s, e)| (start + s, start + e))
}
AnchoredEnd => self.ro.suffixes.find_end(&text),
AnchoredEnd => {
let lits = &self.ro.suffixes;
lits.find_end(&text[start..])
.map(|(s, e)| (start + s, start + e))
}
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use regex::Regex;
mat!(prefix_literal_match, r"^abc", r"abc", Some((0, 3)));
mat!(prefix_literal_nomatch, r"^abc", r"zabc", None);
mat!(one_literal_edge, r"abc", r"xxxxxab", None);
matiter!(terminates, r"a$", r"a", (0, 1));

#[test]
fn eq() {
Expand Down

0 comments on commit cd85664

Please sign in to comment.