]> granicus.if.org Git - clang/commitdiff
[clang-format] Fix crash in getLengthToMatchingParen
authorKrasimir Georgiev <krasimir@google.com>
Tue, 22 May 2018 09:46:55 +0000 (09:46 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Tue, 22 May 2018 09:46:55 +0000 (09:46 +0000)
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

lib/Format/ContinuationIndenter.cpp

index fc4c9115e89141b14149ed58aa25c3a323e15c11..fe6a956839641d80275766bedb7660e969e53dea 100644 (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;