summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/InstrProfWriter.cpp
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
commit6005728843649b782b6a40062caeb14616f1d218 (patch)
tree73287b800af8a9e5bcfe360a0a2fc035e6d18545 /llvm/lib/ProfileData/InstrProfWriter.cpp
parent613c6862fad9a970b1e45e8e2503b71c31a9762a (diff)
downloadbcm5719-llvm-6005728843649b782b6a40062caeb14616f1d218.tar.gz
bcm5719-llvm-6005728843649b782b6a40062caeb14616f1d218.zip
Fix a latent UAF bug in profwriter
llvm-svn: 256116
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 1e18c268892..9bb03e1e77a 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/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) {
OpenPOWER on IntegriCloud