[PATCH] D77468: [clang] fix undefined behaviour in RawComment::getFormattedText()

Raphael Isemann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 6 02:08:42 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGad7211df6f25 (authored by obruns, committed by teemperor).

Changed prior to commit:
  https://reviews.llvm.org/D77468?vs=255059&id=255256#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77468

Files:
  clang/lib/AST/RawCommentList.cpp


Index: clang/lib/AST/RawCommentList.cpp
===================================================================
--- clang/lib/AST/RawCommentList.cpp
+++ clang/lib/AST/RawCommentList.cpp
@@ -431,7 +431,7 @@
   };
 
   auto DropTrailingNewLines = [](std::string &Str) {
-    while (Str.back() == '\n')
+    while (!Str.empty() && Str.back() == '\n')
       Str.pop_back();
   };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77468.255256.patch
Type: text/x-patch
Size: 375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200406/d039a0fd/attachment-0001.bin>


More information about the cfe-commits mailing list