[llvm] r256116 - Fix a latent UAF bug in profwriter

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 20 00:46:24 PST 2015


Author: davidxl
Date: Sun Dec 20 02:46:18 2015
New Revision: 256116

URL: http://llvm.org/viewvc/llvm-project?rev=256116&view=rev
Log:
Fix a latent UAF bug in profwriter

Modified:
    llvm/trunk/lib/ProfileData/InstrProfWriter.cpp

Modified: llvm/trunk/lib/ProfileData/InstrProfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfWriter.cpp?rev=256116&r1=256115&r2=256116&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfWriter.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfWriter.cpp Sun Dec 20 02:46:18 2015
@@ -108,6 +108,8 @@ std::error_code InstrProfWriter::addReco
   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) {




More information about the llvm-commits mailing list