git.iko.soy/typeable/attoparsec
on master help sign in
Fix Int overflow in lengthAtLeast

In addition, the prior check assumed that the length was in bytes, not Word16s, which made it too conservative.

commit33175c34b5bac248d885dea113dda9673aa5c107 authorJohan Tibell <johan.tibell@gmail.com> dateSun 18 Nov 2012, 08:38 (14 years ago) parentfb4a718
1 file changed+1−1
Data/Attoparsec/Text/Internal.hs+1−1
Data/Attoparsec/Text/Internal.hs+1−1
@@ -96,7 +96,7 @@ instance IsString (Parser Text) where
9696 fromString = string . T.pack
9797
9898lengthAtLeast :: T.Text -> Int -> Bool
99−lengthAtLeast t@(T.Text _ _ l) n = l >= n * 4 || T.length t >= n
99+lengthAtLeast t@(T.Text _ _ len) n = (len `div` 2) >= n || T.length t >= n
100100{-# INLINE lengthAtLeast #-}
101101
102102-- | If at least @n@ characters of input are available, return the