From: Krasimir Georgiev Date: Tue, 22 May 2018 09:46:55 +0000 (+0000) Subject: [clang-format] Fix crash in getLengthToMatchingParen X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a96a9be6e7f2e6eee5e2527db1a1bc2f399076cc;p=clang [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 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index fc4c9115e8..fe6a956839 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -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;