[llvm-branch-commits] [llvm-branch] r344918 - Merging r342461:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Oct 22 09:37:14 PDT 2018
Author: tstellar
Date: Mon Oct 22 09:37:14 2018
New Revision: 344918
URL: http://llvm.org/viewvc/llvm-project?rev=344918&view=rev
Log:
Merging r342461:
------------------------------------------------------------------------
r342461 | devnexen | 2018-09-18 03:31:10 -0700 (Tue, 18 Sep 2018) | 10 lines
[Xray] llvm-xray fix possible segfault
top argument when superior to the instrumentated code list capacity can lead to a segfault.
Reviewers: dberris
Reviewed By: dberris
Differential Revision: https://reviews.llvm.org/D52224
------------------------------------------------------------------------
Modified:
llvm/branches/release_70/tools/llvm-xray/xray-account.cpp
Modified: llvm/branches/release_70/tools/llvm-xray/xray-account.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/tools/llvm-xray/xray-account.cpp?rev=344918&r1=344917&r2=344918&view=diff
==============================================================================
--- llvm/branches/release_70/tools/llvm-xray/xray-account.cpp (original)
+++ llvm/branches/release_70/tools/llvm-xray/xray-account.cpp Mon Oct 22 09:37:14 2018
@@ -358,8 +358,11 @@ void LatencyAccountant::exportStats(cons
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));
More information about the llvm-branch-commits
mailing list