summaryrefslogtreecommitdiff
path: root/lib/ProfileData
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-12-20 08:46:18 +0000
committerXinliang David Li <davidxl@google.com>2015-12-20 08:46:18 +0000
commitcb4197f6218bb26900085779bf0cf161535dfbde (patch)
tree0ff521879b54f4c65db34d99a1b8c3dff3d6472d /lib/ProfileData
parent116cc72ed46500eab12fa8e0833d9bb194fcdc2b (diff)
Fix a latent UAF bug in profwriter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ProfileData')
-rw-r--r--lib/ProfileData/InstrProfWriter.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/ProfileData/InstrProfWriter.cpp b/lib/ProfileData/InstrProfWriter.cpp
index 1e18c268892..9bb03e1e77a 100644
--- a/lib/ProfileData/InstrProfWriter.cpp
+++ b/lib/ProfileData/InstrProfWriter.cpp
@@ -108,6 +108,8 @@ std::error_code InstrProfWriter::addRecord(InstrProfRecord &&I,
if (NewFunc) {
// We've never seen a function with this name and hash, add it.
Dest = std::move(I);
+ // Fix up the name to avoid dangling reference.
+ Dest.Name = FunctionData.find(Dest.Name)->getKey();
Result = instrprof_error::success;
if (Weight > 1) {
for (auto &Count : Dest.Counts) {