Skip to content

Commit eb0722e

Browse files
committed
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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@344918 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 888225e commit eb0722e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/llvm-xray/xray-account.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,11 @@ void LatencyAccountant::exportStats(const XRayFileHeader &Header, F Fn) const {
358358
break;
359359
}
360360

361-
if (AccountTop > 0)
362-
Results.erase(Results.begin() + AccountTop.getValue(), Results.end());
361+
if (AccountTop > 0) {
362+
auto MaxTop =
363+
std::min(AccountTop.getValue(), static_cast<int>(Results.size()));
364+
Results.erase(Results.begin() + MaxTop, Results.end());
365+
}
363366

364367
for (const auto &R : Results)
365368
Fn(std::get<0>(R), std::get<1>(R), std::get<2>(R));

0 commit comments

Comments
 (0)