{"id":9398,"date":"2014-08-24T15:54:03","date_gmt":"2014-08-24T19:54:03","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=9398"},"modified":"2014-08-24T15:54:03","modified_gmt":"2014-08-24T19:54:03","slug":"yet-another-integer-underflow-bug","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/08\/24\/yet-another-integer-underflow-bug\/","title":{"rendered":"Yet Another Integer Underflow Bug"},"content":{"rendered":"<p><a href=\"http:\/\/www.wabbo.org\/blog\/2014\/22aug_on_bananas.html\">Nick Hamann<\/a> (via <a href=\"https:\/\/twitter.com\/Catfish_Man\/status\/503333409880424448\">David Smith<\/a>):<\/p>\n<blockquote cite=\"http:\/\/www.wabbo.org\/blog\/2014\/22aug_on_bananas.html\"><p>However, when <code>haystack.len()<\/code> is less than 20, <code>haystack.len() - 20<\/code> will be a very large number; we have an underflow error on our hands. This bug was causing the code to erroneously use the <code>TwoWaySearcher<\/code> in general for haystacks of length less than 20, but in particular for the case of <code>\"bananas\".contains(\"nana\")<\/code>. The fix is to add <code>20<\/code> to the needle instead of subtracting it from the haystack [&#8230;]<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>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 the TwoWaySearcher in general for haystacks of length less than 20, but in particular for the case [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[131,71,408,982],"class_list":["post-9398","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-programming","tag-rust-lang","tag-underflow"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=9398"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9398\/revisions"}],"predecessor-version":[{"id":9399,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9398\/revisions\/9399"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=9398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=9398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=9398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}