[clang-format] Fix crash in getLengthToMatchingParen

Summary:
Found by oss-fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8212

Reviewers: bkramer

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47191

llvm-svn: 332961
This commit is contained in:
Krasimir Georgiev 2018-05-22 09:46:55 +00:00
parent 11d68a619e
commit f163bdc07e
1 changed files with 3 additions and 3 deletions

View File

@ -94,9 +94,9 @@ static unsigned getLengthToMatchingParen(const FormatToken &Tok,
break;
if (!End->Next->closesScope())
continue;
if (End->Next->MatchingParen->isOneOf(tok::l_brace,
TT_ArrayInitializerLSquare,
tok::less)) {
if (End->Next->MatchingParen &&
End->Next->MatchingParen->isOneOf(
tok::l_brace, TT_ArrayInitializerLSquare, tok::less)) {
const ParenState *State = FindParenState(End->Next->MatchingParen);
if (State && State->BreakBeforeClosingBrace)
break;