[analyzer] Eliminate memory leak in BugReporter::emitReport()

llvm-svn: 203507
This commit is contained in:
Anton Yartsev 2014-03-10 22:35:02 +00:00
parent 3fd7a63d67
commit fe50df6983
1 changed files with 5 additions and 2 deletions

View File

@ -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());
}