From cd85664787f5abaab019abebc0681e62db2c6366 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 9 Jul 2016 15:48:16 -0400 Subject: [PATCH] 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. --- src/exec.rs | 6 +++++- tests/misc.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/exec.rs b/src/exec.rs index 87c3e84dab..755342497b 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -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)) + } } } diff --git a/tests/misc.rs b/tests/misc.rs index 4fba750359..293cddb322 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -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() {