[commit: packages/bytestring] 0.10.4.x, master: Fix Int overflow in Lazy.toStrict (fbcc0af)

git at git.haskell.org git at git.haskell.org
Fri Jan 23 22:42:34 UTC 2015


Repository : ssh://git@git.haskell.org/bytestring

On branches: 0.10.4.x,master
Link       : http://git.haskell.org/packages/bytestring.git/commitdiff/fbcc0afc65de06e5de0fe05054539452f59ffeb9

>---------------------------------------------------------------

commit fbcc0afc65de06e5de0fe05054539452f59ffeb9
Author: Bryan O'Sullivan <bos at serpentine.com>
Date:   Fri Jun 6 14:43:15 2014 -0700

    Fix Int overflow in Lazy.toStrict
    
    This is the final fix for gh-22.


>---------------------------------------------------------------

fbcc0afc65de06e5de0fe05054539452f59ffeb9
 Data/ByteString/Lazy.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Data/ByteString/Lazy.hs b/Data/ByteString/Lazy.hs
index 52d1c0f..c761bdb 100644
--- a/Data/ByteString/Lazy.hs
+++ b/Data/ByteString/Lazy.hs
@@ -295,7 +295,7 @@ toStrict Empty           = S.empty
 toStrict (Chunk c Empty) = c
 toStrict cs0 = S.unsafeCreate totalLen $ \ptr -> go cs0 ptr
   where
-    totalLen = foldlChunks (\a c -> a + S.length c) 0 cs0
+    totalLen = S.checkedSum "Lazy.toStrict" . L.map S.length . toChunks $ cs0
 
     go Empty                        !_       = return ()
     go (Chunk (S.PS fp off len) cs) !destptr =



More information about the ghc-commits mailing list