Commits

tibbe committed 53b0cf6

Fix Int overflow in lengthAtLeast

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

  • Participants
  • Parent commits c2aac31

Comments (0)

Files changed (1)

File Data/Attoparsec/Text/Internal.hs

     fromString = string . T.pack
 
 lengthAtLeast :: T.Text -> Int -> Bool
-lengthAtLeast t@(T.Text _ _ l) n = l >= n * 4 || T.length t >= n
+lengthAtLeast t@(T.Text _ _ len) n = (len `div` 2) >= n || T.length t >= n
 {-# INLINE lengthAtLeast #-}
 
 -- | If at least @n@ characters of input are available, return the