r208251 - NSOrCFErrorDerefChecker: Don't leak bug type. Similar to r208110/r208155. Found by LSan.
Nico Weber
nicolasweber at gmx.de
Wed May 7 14:28:03 PDT 2014
Author: nico
Date: Wed May 7 16:28:03 2014
New Revision: 208251
URL: http://llvm.org/viewvc/llvm-project?rev=208251&view=rev
Log:
NSOrCFErrorDerefChecker: Don't leak bug type. Similar to r208110/r208155. Found by LSan.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp?rev=208251&r1=208250&r2=208251&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp Wed May 7 16:28:03 2014
@@ -153,6 +153,8 @@ class NSOrCFErrorDerefChecker
: public Checker< check::Location,
check::Event<ImplicitNullDerefEvent> > {
mutable IdentifierInfo *NSErrorII, *CFErrorII;
+ mutable std::unique_ptr<NSErrorDerefBug> NSBT;
+ mutable std::unique_ptr<CFErrorDerefBug> CFBT;
public:
bool ShouldCheckNSError, ShouldCheckCFError;
NSOrCFErrorDerefChecker() : NSErrorII(0), CFErrorII(0),
@@ -263,10 +265,16 @@ void NSOrCFErrorDerefChecker::checkEvent
os << " may be null";
BugType *bug = 0;
- if (isNSError)
- bug = new NSErrorDerefBug(this);
- else
- bug = new CFErrorDerefBug(this);
+ if (isNSError) {
+ if (!NSBT)
+ NSBT.reset(new NSErrorDerefBug(this));
+ bug = NSBT.get();
+ }
+ else {
+ if (!CFBT)
+ CFBT.reset(new CFErrorDerefBug(this));
+ bug = CFBT.get();
+ }
BugReport *report = new BugReport(*bug, os.str(), event.SinkNode);
BR.emitReport(report);
}
More information about the cfe-commits
mailing list