Yet Another Integer Underflow Bug
Nick Hamann (via David Smith):
However, when
haystack.len()
is less than 20,haystack.len() - 20
will be a very large number; we have an underflow error on our hands. This bug was causing the code to erroneously use theTwoWaySearcher
in general for haystacks of length less than 20, but in particular for the case of"bananas".contains("nana")
. The fix is to add20
to the needle instead of subtracting it from the haystack […]