]> granicus.if.org Git - clang/commitdiff
[clang-format] Add a test case for crash
authorKrasimir Georgiev <krasimir@google.com>
Tue, 22 May 2018 11:44:03 +0000 (11:44 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Tue, 22 May 2018 11:44:03 +0000 (11:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332974 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Format/FormatTest.cpp

index 3f9e805631425d66c0c7818ad9dc8d031c8f1655..624b086a21621b1adb487355248ff940d9a22a1a 100644 (file)
@@ -6628,6 +6628,18 @@ TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) {
   verifyNoCrash("(/**/[:!] ?[).");
 }
 
+TEST_F(FormatTest, IncorrectUnbalancedBracesInMacrosWithUnicode) {
+  // Found by oss-fuzz:
+  // https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8212
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
+  Style.ColumnLimit = 60;
+  verifyNoCrash(
+      "\x23\x47\xff\x20\x28\xff\x3c\xff\x3f\xff\x20\x2f\x7b\x7a\xff\x20"
+      "\xff\xff\xff\xca\xb5\xff\xff\xff\xff\x3a\x7b\x7d\xff\x20\xff\x20"
+      "\xff\x74\xff\x20\x7d\x7d\xff\x7b\x3a\xff\x20\x71\xff\x20\xff\x0a",
+      Style);
+}
+
 TEST_F(FormatTest, IncorrectCodeDoNoWhile) {
   verifyFormat("do {\n}");
   verifyFormat("do {\n}\n"