Skip to content

Commit

Permalink
Reset the lazy decoder state consistently if an error occurs
Browse files Browse the repository at this point in the history
This fixes gh-87.
  • Loading branch information
bos committed Sep 8, 2014
1 parent e661fd8 commit 2925921
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Data/Text/Encoding.hs
Expand Up @@ -267,14 +267,14 @@ 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
destOff <- peek destOffPtr
w <- unsafeSTToIO $
unsafeWrite dest (fromIntegral destOff) (safe c)
poke destOffPtr (destOff + fromIntegral w)
poke statePtr 0
loop $ curPtr' `plusPtr` 1

_ -> do
Expand Down

0 comments on commit 2925921

Please sign in to comment.