]> granicus.if.org Git - clang/commitdiff
isLegalUTF8() was giving the wrong answer
authorSeth Cantrell <seth.cantrell@gmail.com>
Tue, 30 Oct 2012 23:50:26 +0000 (23:50 +0000)
committerSeth Cantrell <seth.cantrell@gmail.com>
Tue, 30 Oct 2012 23:50:26 +0000 (23:50 +0000)
invalid but not caught by isLegalUTF8(): 0xED 0x75 0x84

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167063 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/ConvertUTF.c

index ec57be701add9f8e8e0e0218ca64ab9650f443f3..d16965ddd872d47845a3cf73bdd75090fc42fd94 100644 (file)
@@ -359,7 +359,7 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
         /* Everything else falls through when "true"... */
     case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
     case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
-    case 2: if ((a = (*--srcptr)) > 0xBF) return false;
+    case 2: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
 
         switch (*source) {
             /* no fall-through in this inner switch */