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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 12:04:19 PST 2015


On Thu, Oct 29, 2015 at 5:49 AM, Daniel Jasper via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> 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),
>

Tidied this up a bit further in r251823, avoiding the need for a temporary
string by StringRef-ifying the DiagnosticInfoSampleProfile ctor/member/etc.


>            Twine(CoverageTracker.getNumUsedSamples(Samples)) + " of " +
>                Twine(Samples->getBodySamples().size()) +
>                " available profile records (" + Twine(Coverage) +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151102/5c3e23e8/attachment.html>


More information about the llvm-commits mailing list