about summary refs log tree commit diff
diff options
context:
space:
mode:
authornham <hamann.nick@gmail.com>2014-08-18 17:51:51 -0400
committernham <hamann.nick@gmail.com>2014-08-18 17:51:51 -0400
commita4bbb5bab4ea49bc0f4cb9638f27a7eb68e1bdb6 (patch)
tree5018555b946ec5da5278afb7ef35bc54d4b4e451
parent98ec85f19e42edafc3d82a737f0ccbd1b7f4ff6c (diff)
downloadrust-a4bbb5bab4ea49bc0f4cb9638f27a7eb68e1bdb6.tar.gz
rust-a4bbb5bab4ea49bc0f4cb9638f27a7eb68e1bdb6.zip
Fix underflow bug in core::str::Searcher::new for haystacks of length < 20
-rw-r--r--src/libcore/str.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 095605326c7..800e2dcc278 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -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);