forked from OSchip/llvm-project
[analyzer] Eliminate memory leak in BugReporter::emitReport()
llvm-svn: 203507
This commit is contained in:
parent
3fd7a63d67
commit
fe50df6983
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue