Skip to content

Commit

Permalink
Fix underflow bug in core::str::Searcher::new for haystacks of length…
Browse files Browse the repository at this point in the history
… < 20
  • Loading branch information
nham committed Aug 18, 2014
1 parent 98ec85f commit a4bbb5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libcore/str.rs
Expand Up @@ -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);
Expand Down

0 comments on commit a4bbb5b

Please sign in to comment.