summaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/BugReporter.cpp
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
commite018c7b00c8d3b4c506efe266bf30f77f7d9b589 (patch)
treecb2044f1dfbcc388f492352550aa6f18f658be35 /lib/StaticAnalyzer/Core/BugReporter.cpp
parent22ee0a5ea39c9b3442d04e3e6df7065111a606c1 (diff)
downloadclang-e018c7b00c8d3b4c506efe266bf30f77f7d9b589.tar.gz
clang-e018c7b00c8d3b4c506efe266bf30f77f7d9b589.tar.bz2
clang-e018c7b00c8d3b4c506efe266bf30f77f7d9b589.tar.xz
[analyzer] Eliminate memory leak in BugReporter::emitReport()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 1b55cdec58..387a0eb396 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/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());
}