<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 29, 2015 at 5:49 AM, Daniel Jasper via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: djasper<br>
Date: Thu Oct 29 07:49:37 2015<br>
New Revision: 251623<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=251623&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=251623&view=rev</a><br>
Log:<br>
Fix use-after-free. Thanks ASAN for giving me a detailed report :-).<br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=251623&r1=251622&r2=251623&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=251623&r1=251622&r2=251623&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Thu Oct 29 07:49:37 2015<br>
@@ -380,9 +380,9 @@ bool SampleProfileLoader::computeBlockWe<br>
   if (SampleProfileCoverage) {<br>
     unsigned Coverage = CoverageTracker.computeCoverage(Samples);<br>
     if (Coverage < SampleProfileCoverage) {<br>
-      const char *Filename = getDISubprogram(&F)->getFilename().str().c_str();<br>
+      StringRef Filename = getDISubprogram(&F)->getFilename();<br>
       F.getContext().diagnose(DiagnosticInfoSampleProfile(<br>
-          Filename, getFunctionLoc(F),<br>
+          Filename.str().c_str(), getFunctionLoc(F),<br></blockquote><div><br></div><div>Tidied this up a bit further in r251823, avoiding the need for a temporary string by StringRef-ifying the DiagnosticInfoSampleProfile ctor/member/etc.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
           Twine(CoverageTracker.getNumUsedSamples(Samples)) + " of " +<br>
               Twine(Samples->getBodySamples().size()) +<br>
               " available profile records (" + Twine(Coverage) +<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>