on master help sign in
Reset the lazy decoder state consistently if an error occurs

This fixes gh-87.

commit2925921bd960c6820c7caa8b77d233c36ad83149 authorBryan O'Sullivan <bos@serpentine.com> dateMon 8 Sep 2014, 16:50 (12 years ago) parente661fd8
1 file changed+1−1
Data/Text/Encoding.hs+1−1
Data/Text/Encoding.hs+1−1
@@ -267,6 +267,7 @@ streamDecodeUtf8With onErr = decodeChunk B.empty 0 0
267267 UTF8_REJECT -> do
268268 -- We encountered an encoding error
269269 x <- peek curPtr'
270+ poke statePtr 0
270271 case onErr desc (Just x) of
271272 Nothing -> loop $ curPtr' `plusPtr` 1
272273 Just c -> do
@@ -274,7 +275,6 @@ streamDecodeUtf8With onErr = decodeChunk B.empty 0 0
274275 w <- unsafeSTToIO $
275276 unsafeWrite dest (fromIntegral destOff) (safe c)
276277 poke destOffPtr (destOff + fromIntegral w)
277− poke statePtr 0
278278 loop $ curPtr' `plusPtr` 1
279279
280280 _ -> do