The length of valid codepoints was incorrectly
calculated which was not caught before because the
absence of tests for the valid codepoints scenario.
Differential Revision: https://reviews.llvm.org/D129223
// abcd
// \80abcd
// expected-warning@-1 {{invalid UTF-8 in comment}}
+
+
+//§ § § 😀 你好 ©
+
+/*§ § § 😀 你好 ©*/
+
+/*
+§ § § 😀 你好 ©
+*/
+
+/* § § § 😀 你好 © */
*/
unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
int length = trailingBytesForUTF8[*source] + 1;
- return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+ return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length
: 0;
}