From 4da93a6599abc2380213192bef506840e863c877 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 29 Oct 2015 12:49:37 +0000 Subject: [PATCH] Fix use-after-free. Thanks ASAN for giving me a detailed report :-). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251623 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/SampleProfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/IPO/SampleProfile.cpp b/lib/Transforms/IPO/SampleProfile.cpp index 47250cccc4d..51e95a5887a 100644 --- a/lib/Transforms/IPO/SampleProfile.cpp +++ b/lib/Transforms/IPO/SampleProfile.cpp @@ -380,9 +380,9 @@ bool SampleProfileLoader::computeBlockWeights(Function &F) { 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) + -- 2.34.1