diff options
| author | nham <hamann.nick@gmail.com> | 2014-09-02 01:53:12 -0400 |
|---|---|---|
| committer | nham <hamann.nick@gmail.com> | 2014-09-02 01:53:12 -0400 |
| commit | e9db8adebb9fe9c7f65266127fca926ff736b740 (patch) | |
| tree | c01127794674412a2814437ef8c38615a1c5ade9 | |
| parent | 0bdac78da87605f6f7f6e7924872617226b19c85 (diff) | |
| download | rust-e9db8adebb9fe9c7f65266127fca926ff736b740.tar.gz rust-e9db8adebb9fe9c7f65266127fca926ff736b740.zip | |
core: Make TwoWaySearcher reset its prefix memory when shifting by byteset
Closes #16878.
| -rw-r--r-- | src/libcore/str.rs | 3 | ||||
| -rw-r--r-- | src/libcoretest/str.rs | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs index b067e6299ee..c8325fbcd80 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -479,6 +479,9 @@ impl TwoWaySearcher { ((haystack[self.position + needle.len() - 1] & 0x3f) as uint)) & 1 == 0 { self.position += needle.len(); + if !long_period { + self.memory = 0; + } continue 'search; } diff --git a/src/libcoretest/str.rs b/src/libcoretest/str.rs index be2275dcd4a..51bd72ec014 100644 --- a/src/libcoretest/str.rs +++ b/src/libcoretest/str.rs @@ -26,6 +26,12 @@ fn strslice_issue_16589() { check_contains_all_substrings("012345678901234567890123456789bcdabcdabcd"); } +#[test] +fn strslice_issue_16878() { + assert!(!"1234567ah012345678901ah".contains("hah")); + assert!(!"00abc01234567890123456789abc".contains("bcabc")); +} + #[test] fn test_strslice_contains() { |
