[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 llvm-svn: 342461
This commit is contained in:
parent
821a116818
commit
38a20c2a52
|
@ -358,8 +358,11 @@ void LatencyAccountant::exportStats(const XRayFileHeader &Header, F Fn) const {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AccountTop > 0)
|
if (AccountTop > 0) {
|
||||||
Results.erase(Results.begin() + AccountTop.getValue(), Results.end());
|
auto MaxTop =
|
||||||
|
std::min(AccountTop.getValue(), static_cast<int>(Results.size()));
|
||||||
|
Results.erase(Results.begin() + MaxTop, Results.end());
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &R : Results)
|
for (const auto &R : Results)
|
||||||
Fn(std::get<0>(R), std::get<1>(R), std::get<2>(R));
|
Fn(std::get<0>(R), std::get<1>(R), std::get<2>(R));
|
||||||
|
|
Loading…
Reference in New Issue