[PATCH] D138371: [clang-format] Fix a crash due to dereferencing null MatchingParen

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 19 19:17:34 PST 2022


owenpan created this revision.
owenpan added reviewers: HazardyKnusperkeks, MyDeveloperDay, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/59089.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138371

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2852,6 +2852,8 @@
           return false;
       } else if (isCppAttribute(IsCpp, *Next)) {
         Next = Next->MatchingParen;
+        if (!Next)
+          return false;
       } else if (Next->is(tok::l_paren)) {
         break;
       } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138371.476717.patch
Type: text/x-patch
Size: 446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221120/5db2f841/attachment.bin>


More information about the cfe-commits mailing list