summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorAnton Yartsev <anton.yartsev@gmail.com>2014-03-10 22:35:02 +0000
committerAnton Yartsev <anton.yartsev@gmail.com>2014-03-10 22:35:02 +0000
commitfe50df69838420c6b9f04d7438e4c95a203c5a25 (patch)
tree07ff377215956d479f7fc01f8255caa8a64b22be /clang/lib/StaticAnalyzer
parent3fd7a63d67ba31c0d59ba66fe524b9c04562396a (diff)
downloadbcm5719-llvm-fe50df69838420c6b9f04d7438e4c95a203c5a25.tar.gz
bcm5719-llvm-fe50df69838420c6b9f04d7438e4c95a203c5a25.zip
[analyzer] Eliminate memory leak in BugReporter::emitReport()
llvm-svn: 203507
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 1b55cdec589..387a0eb396e 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3243,6 +3243,9 @@ void BugReporter::Register(BugType *BT) {
}
void BugReporter::emitReport(BugReport* R) {
+ // To guarantee memory release.
+ std::unique_ptr<BugReport> UniqueR(R);
+
// Defensive checking: throw the bug away if it comes from a BodyFarm-
// generated body. We do this very early because report processing relies
// on the report's location being valid.
@@ -3273,12 +3276,12 @@ void BugReporter::emitReport(BugReport* R) {
BugReportEquivClass* EQ = EQClasses.FindNodeOrInsertPos(ID, InsertPos);
if (!EQ) {
- EQ = new BugReportEquivClass(R);
+ EQ = new BugReportEquivClass(UniqueR.release());
EQClasses.InsertNode(EQ, InsertPos);
EQClassesVector.push_back(EQ);
}
else
- EQ->AddReport(R);
+ EQ->AddReport(UniqueR.release());
}
OpenPOWER on IntegriCloud