Skip to content

Commit

Permalink
Fix bug in isValidUtf8ByteArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Lysxia committed Jan 25, 2024
1 parent 5f0e1d1 commit a0cf03a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Data/Text/Internal/Validate/Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ isValidUtf8ByteArrayHaskell (ByteArray b) !off !len = start off
indexWord8 :: ByteArray# -> Int -> Word8
indexWord8 !x (I# i) = W8# (indexWord8Array# x i)
start ix
| ix >= len = True
| ix >= off + len = True
| otherwise = case utf8DecodeStart (indexWord8 b ix) of
Accept{} -> start (ix + 1)
Reject{} -> False
Incomplete st _ -> step (ix + 1) st
step ix st
| ix >= len = False
| ix >= off + len = False
-- We do not use decoded code point, so passing a dummy value to save an argument.
| otherwise = case utf8DecodeContinue (indexWord8 b ix) st (CodePoint 0) of
Accept{} -> start (ix + 1)
Expand Down

0 comments on commit a0cf03a

Please sign in to comment.