mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-01 12:43:47 +00:00
clang-format: Fix crasher when splitting incomplete escape sequences.
llvm-svn: 226698
This commit is contained in:
parent
97a01f0161
commit
e4b48c635c
@ -106,7 +106,7 @@ getStringSplit(StringRef Text, unsigned UsedColumns, unsigned ColumnLimit,
|
||||
Text.substr(0, Advance), UsedColumns + Chars, TabWidth, Encoding);
|
||||
}
|
||||
|
||||
if (Chars > MaxSplit || Text.size() == Advance)
|
||||
if (Chars > MaxSplit || Text.size() <= Advance)
|
||||
break;
|
||||
|
||||
if (IsBlank(Text[0]))
|
||||
|
@ -7444,6 +7444,12 @@ TEST_F(FormatTest, BreaksWideAndNSStringLiterals) {
|
||||
EXPECT_EQ("@\"NSString \"\n"
|
||||
"@\"literal\";",
|
||||
format("@\"NSString literal\";", getGoogleStyleWithColumns(19)));
|
||||
|
||||
// This input makes clang-format try to split the incomplete unicode escape
|
||||
// sequence, which used to lead to a crasher.
|
||||
verifyNoCrash(
|
||||
"aaaaaaaaaaaaaaaaaaaa = L\"\\udff\"'; // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
getLLVMStyleWithColumns(60));
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, DoesNotBreakRawStringLiterals) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user