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 {
|
impl Searcher {
|
||||||
fn new(haystack: &[u8], needle: &[u8]) -> Searcher {
|
fn new(haystack: &[u8], needle: &[u8]) -> Searcher {
|
||||||
// FIXME: Tune this.
|
// FIXME: Tune this.
|
||||||
if needle.len() > haystack.len() - 20 {
|
if needle.len() + 20 > haystack.len() {
|
||||||
Naive(NaiveSearcher::new())
|
Naive(NaiveSearcher::new())
|
||||||
} else {
|
} else {
|
||||||
let searcher = TwoWaySearcher::new(needle);
|
let searcher = TwoWaySearcher::new(needle);
|
||||||
|
Loading…
Reference in New Issue
Block a user