[PATCH] D52224: [Xray] llvm-xray fix possible segfault
David CARLIER via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 18 02:47:55 PDT 2018
devnexen created this revision.
devnexen added a reviewer: dberris.
devnexen created this object with visibility "All Users".
Herald added a subscriber: llvm-commits.
- top argument when superior to the instrumentated code list capacity can lead to a segfault.
Repository:
rL LLVM
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,10 @@
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.end() - Results.begin()));
+ 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.165910.patch
Type: text/x-patch
Size: 607 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/612adbc6/attachment.bin>
More information about the llvm-commits
mailing list