From 2925921bd960c6820c7caa8b77d233c36ad83149 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan <bos@serpentine.com> Date: Mon, 8 Sep 2014 16:50:52 -0700 Subject: [PATCH] Reset the lazy decoder state consistently if an error occurs This fixes gh-87. --- Data/Text/Encoding.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Text/Encoding.hs b/Data/Text/Encoding.hs index b1c39c78..f21e6a29 100644 --- a/Data/Text/Encoding.hs +++ b/Data/Text/Encoding.hs @@ -267,6 +267,7 @@ streamDecodeUtf8With onErr = decodeChunk B.empty 0 0 UTF8_REJECT -> do -- We encountered an encoding error x <- peek curPtr' + poke statePtr 0 case onErr desc (Just x) of Nothing -> loop $ curPtr' `plusPtr` 1 Just c -> do @@ -274,7 +275,6 @@ streamDecodeUtf8With onErr = decodeChunk B.empty 0 0 w <- unsafeSTToIO $ unsafeWrite dest (fromIntegral destOff) (safe c) poke destOffPtr (destOff + fromIntegral w) - poke statePtr 0 loop $ curPtr' `plusPtr` 1 _ -> do -- GitLab