Browse Source

[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332961 91177308-0d34-0410-b5e6-96231b3b80d8
Krasimir Georgiev 7 years ago
parent
commit
a96a9be6e7
1 changed files with 3 additions and 3 deletions
  1. 3 3
      lib/Format/ContinuationIndenter.cpp

+ 3 - 3
lib/Format/ContinuationIndenter.cpp

@@ -94,9 +94,9 @@ static unsigned getLengthToMatchingParen(const FormatToken &Tok,
       break;
       break;
     if (!End->Next->closesScope())
     if (!End->Next->closesScope())
       continue;
       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);
       const ParenState *State = FindParenState(End->Next->MatchingParen);
       if (State && State->BreakBeforeClosingBrace)
       if (State && State->BreakBeforeClosingBrace)
         break;
         break;