Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Don't ignore the start offset when searching for an anchored literal.
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
commit cd85664787f5abaab019abebc0681e62db2c6366
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