NSOrCFErrorDerefChecker: Don't leak bug type. Similar to r208110/r208155. Found by LSan.
llvm-svn: 208251
This commit is contained in:
parent
2fccdfbe70
commit
1fa575dcc6
|
@ -153,6 +153,8 @@ class NSOrCFErrorDerefChecker
|
||||||
: public Checker< check::Location,
|
: public Checker< check::Location,
|
||||||
check::Event<ImplicitNullDerefEvent> > {
|
check::Event<ImplicitNullDerefEvent> > {
|
||||||
mutable IdentifierInfo *NSErrorII, *CFErrorII;
|
mutable IdentifierInfo *NSErrorII, *CFErrorII;
|
||||||
|
mutable std::unique_ptr<NSErrorDerefBug> NSBT;
|
||||||
|
mutable std::unique_ptr<CFErrorDerefBug> CFBT;
|
||||||
public:
|
public:
|
||||||
bool ShouldCheckNSError, ShouldCheckCFError;
|
bool ShouldCheckNSError, ShouldCheckCFError;
|
||||||
NSOrCFErrorDerefChecker() : NSErrorII(0), CFErrorII(0),
|
NSOrCFErrorDerefChecker() : NSErrorII(0), CFErrorII(0),
|
||||||
|
@ -263,10 +265,16 @@ void NSOrCFErrorDerefChecker::checkEvent(ImplicitNullDerefEvent event) const {
|
||||||
os << " may be null";
|
os << " may be null";
|
||||||
|
|
||||||
BugType *bug = 0;
|
BugType *bug = 0;
|
||||||
if (isNSError)
|
if (isNSError) {
|
||||||
bug = new NSErrorDerefBug(this);
|
if (!NSBT)
|
||||||
else
|
NSBT.reset(new NSErrorDerefBug(this));
|
||||||
bug = new CFErrorDerefBug(this);
|
bug = NSBT.get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!CFBT)
|
||||||
|
CFBT.reset(new CFErrorDerefBug(this));
|
||||||
|
bug = CFBT.get();
|
||||||
|
}
|
||||||
BugReport *report = new BugReport(*bug, os.str(), event.SinkNode);
|
BugReport *report = new BugReport(*bug, os.str(), event.SinkNode);
|
||||||
BR.emitReport(report);
|
BR.emitReport(report);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue