[PATCH] D52224: [Xray] llvm-xray fix possible segfault

David CARLIER via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 18 03:32:39 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342461: [Xray] llvm-xray fix possible segfault (authored by devnexen, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52224?vs=165914&id=165925#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52224

Files:
  llvm/trunk/tools/llvm-xray/xray-account.cpp


Index: llvm/trunk/tools/llvm-xray/xray-account.cpp
===================================================================
--- llvm/trunk/tools/llvm-xray/xray-account.cpp
+++ llvm/trunk/tools/llvm-xray/xray-account.cpp
@@ -358,8 +358,11 @@
     break;
   }
 
-  if (AccountTop > 0)
-    Results.erase(Results.begin() + AccountTop.getValue(), Results.end());
+  if (AccountTop > 0) {
+    auto MaxTop =
+        std::min(AccountTop.getValue(), static_cast<int>(Results.size()));
+    Results.erase(Results.begin() + MaxTop, Results.end());
+  }
 
   for (const auto &R : Results)
     Fn(std::get<0>(R), std::get<1>(R), std::get<2>(R));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52224.165925.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/0669f043/attachment.bin>


More information about the llvm-commits mailing list