[PATCH] D127183: [clang-format] Skip parsing a block if it's nested too deep
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 7 04:34:07 PDT 2022
owenpan updated this revision to Diff 434773.
owenpan added a comment.
Inadvertently moved the added code down when rebasing. Fixed.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127183/new/
https://reviews.llvm.org/D127183
Files:
clang/lib/Format/UnwrappedLineParser.cpp
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -842,6 +842,10 @@
unsigned InitialLevel = Line->Level;
nextToken(/*LevelDifference=*/AddLevels);
+ // Bail out if there are too many levels. Otherwise, the stack might overflow.
+ if (Line->Level > 300)
+ return;
+
if (MacroBlock && FormatTok->is(tok::l_paren))
parseParens();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127183.434773.patch
Type: text/x-patch
Size: 509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220607/da7c7c32/attachment.bin>
More information about the cfe-commits
mailing list