[llvm] r251623 - Fix use-after-free. Thanks ASAN for giving me a detailed report :-).

Daniel Jasper via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 29 05:49:38 PDT 2015


Author: djasper
Date: Thu Oct 29 07:49:37 2015
New Revision: 251623

URL: http://llvm.org/viewvc/llvm-project?rev=251623&view=rev
Log:
Fix use-after-free. Thanks ASAN for giving me a detailed report :-).

Modified:
    llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp

Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=251623&r1=251622&r2=251623&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Thu Oct 29 07:49:37 2015
@@ -380,9 +380,9 @@ bool SampleProfileLoader::computeBlockWe
   if (SampleProfileCoverage) {
     unsigned Coverage = CoverageTracker.computeCoverage(Samples);
     if (Coverage < SampleProfileCoverage) {
-      const char *Filename = getDISubprogram(&F)->getFilename().str().c_str();
+      StringRef Filename = getDISubprogram(&F)->getFilename();
       F.getContext().diagnose(DiagnosticInfoSampleProfile(
-          Filename, getFunctionLoc(F),
+          Filename.str().c_str(), getFunctionLoc(F),
           Twine(CoverageTracker.getNumUsedSamples(Samples)) + " of " +
               Twine(Samples->getBodySamples().size()) +
               " available profile records (" + Twine(Coverage) +




More information about the llvm-commits mailing list