From 97080d8293694fbf4e51556352e3fd196a43bdde Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 2 Jul 2009 08:14:15 +0000 Subject: [PATCH] a byte between 0x80 and 0xBF is illegal immediately (#3341) --- GHC/IO/Encoding/UTF8.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GHC/IO/Encoding/UTF8.hs b/GHC/IO/Encoding/UTF8.hs index 0efb187..99928e0 100644 --- a/GHC/IO/Encoding/UTF8.hs +++ b/GHC/IO/Encoding/UTF8.hs @@ -83,7 +83,7 @@ utf8_decode if not (validate3 c0 c1 c2) then invalid else do writeCharBuf oraw ow (chr3 c0 c1 c2) loop (ir+3) (ow+1) - | otherwise -> + | c0 >= 0xf0 -> if iw - ir < 4 then done ir ow else do c1 <- readWord8Buf iraw (ir+1) c2 <- readWord8Buf iraw (ir+2) @@ -91,6 +91,8 @@ utf8_decode if not (validate4 c0 c1 c2 c3) then invalid else do writeCharBuf oraw ow (chr4 c0 c1 c2 c3) loop (ir+4) (ow+1) + | otherwise -> + invalid where invalid = if ir > ir0 then done ir ow else ioe_decodingError -- 1.7.10.4