Fix underflow bug in core::str::Searcher::new for haystacks of length < 20
This commit is contained in:
parent
98ec85f19e
commit
a4bbb5bab4
@ -562,7 +562,7 @@ enum Searcher {
|
||||
impl Searcher {
|
||||
fn new(haystack: &[u8], needle: &[u8]) -> Searcher {
|
||||
// FIXME: Tune this.
|
||||
if needle.len() > haystack.len() - 20 {
|
||||
if needle.len() + 20 > haystack.len() {
|
||||
Naive(NaiveSearcher::new())
|
||||
} else {
|
||||
let searcher = TwoWaySearcher::new(needle);
|
||||
|
Loading…
Reference in New Issue
Block a user