[analyzer] Fix a leak found by LSan.

PR19524

llvm-svn: 207001
This commit is contained in:
Jordan Rose 2014-04-23 16:54:52 +00:00
parent 6b4bed4b83
commit e811ab9582
1 changed files with 4 additions and 4 deletions

View File

@ -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<PathDiagnosticPiece> 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