]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix a leak found by LSan.
authorJordan Rose <jordan_rose@apple.com>
Wed, 23 Apr 2014 16:54:52 +0000 (16:54 +0000)
committerJordan Rose <jordan_rose@apple.com>
Wed, 23 Apr 2014 16:54:52 +0000 (16:54 +0000)
PR19524

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207001 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/BugReporter.cpp

index ea6af07f347835a6ef9d4d4cde3cd084ceee3d04..6569141b517b70748c61f0217b1603807f4677b6 100644 (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