Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2018-10-22 19:37:14 +0300
committerTom Stellard <tstellar@redhat.com>2018-10-22 19:37:14 +0300
commitdfebe573431425a385738e5644ea417d67f87689 (patch)
tree17734d8550af21cce63a2367401e8dde6843a4c8
parent0447cd66a07d649515953ce36caacd849a1d390c (diff)
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 ------------------------------------------------------------------------ llvm-svn: 344918
-rw-r--r--llvm/tools/llvm-xray/xray-account.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/tools/llvm-xray/xray-account.cpp b/llvm/tools/llvm-xray/xray-account.cpp
index 2776a8888481..77de1de496f6 100644
--- a/llvm/tools/llvm-xray/xray-account.cpp
+++ b/llvm/tools/llvm-xray/xray-account.cpp
@@ -358,8 +358,11 @@ void LatencyAccountant::exportStats(const XRayFileHeader &Header, F Fn) const {
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));