[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:08:31 PDT 2018
devnexen updated this revision to Diff 165914.
https://reviews.llvm.org/D52224
Files:
tools/llvm-xray/xray-account.cpp
Index: tools/llvm-xray/xray-account.cpp
===================================================================
--- tools/llvm-xray/xray-account.cpp
+++ 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.165914.patch
Type: text/x-patch
Size: 599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/05a1ad2d/attachment.bin>
More information about the llvm-commits
mailing list