From: Jordan Rose Date: Wed, 23 Apr 2014 16:54:52 +0000 (+0000) Subject: [analyzer] Fix a leak found by LSan. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=022878f852c61803d260da295a8f905aaf2edad6;p=clang [analyzer] Fix a leak found by LSan. PR19524 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207001 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index ea6af07f34..6569141b51 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -3149,21 +3149,21 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD, // Generate the very last diagnostic piece - the piece is visible before // the trace is expanded. - PathDiagnosticPiece *LastPiece = 0; + std::unique_ptr LastPiece; for (BugReport::visitor_iterator I = visitors.begin(), E = visitors.end(); I != E; ++I) { if (PathDiagnosticPiece *Piece = (*I)->getEndPath(PDB, N, *R)) { assert (!LastPiece && "There can only be one final piece in a diagnostic."); - LastPiece = Piece; + LastPiece.reset(Piece); } } if (ActiveScheme != PathDiagnosticConsumer::None) { if (!LastPiece) - LastPiece = BugReporterVisitor::getDefaultEndPath(PDB, N, *R); + LastPiece.reset(BugReporterVisitor::getDefaultEndPath(PDB, N, *R)); assert(LastPiece); - PD.setEndOfPath(LastPiece); + PD.setEndOfPath(LastPiece.release()); } // Make sure we get a clean location context map so we don't