[PATCH] D129064: [clang-format] Avoid crash in LevelIndentTracker.

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 4 14:46:38 PDT 2022


owenpan added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:69-70
     } else {
-      IndentForLevel.resize(Line.Level + 1);
+      if (IndentForLevel.size() < Line.Level + 1)
+        IndentForLevel.resize(Line.Level + 1);
       Indent = getIndent(Line.Level);
----------------
You can delete both lines as the body of the `if` statement is unreachable. (After the `while` loop on lines 62-63, `IndentForLevel.size()` is larger than `Line.Level`.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129064/new/

https://reviews.llvm.org/D129064



More information about the cfe-commits mailing list