[PATCH] D47191: [clang-format] Fix crash in getLengthToMatchingParen

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 22 02:48:49 PDT 2018


krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

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


Repository:
  rC Clang

https://reviews.llvm.org/D47191

Files:
  lib/Format/ContinuationIndenter.cpp


Index: lib/Format/ContinuationIndenter.cpp
===================================================================
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -94,9 +94,9 @@
       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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47191.147971.patch
Type: text/x-patch
Size: 754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180522/918f5421/attachment.bin>


More information about the cfe-commits mailing list