@@ -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