summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-05-07 21:28:03 +0000
committerNico Weber <nicolasweber@gmx.de>2014-05-07 21:28:03 +0000
commit1fa575dcc6f47363ff7dcf78a4be359c0343c7e5 (patch)
treeaa2b2e255c702b3e62d52620069e2d24a9dca033 /clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
parent2fccdfbe70c95aa4e010d77c2d19fa5e0deb5d2e (diff)
downloadbcm5719-llvm-1fa575dcc6f47363ff7dcf78a4be359c0343c7e5.tar.gz
bcm5719-llvm-1fa575dcc6f47363ff7dcf78a4be359c0343c7e5.zip
NSOrCFErrorDerefChecker: Don't leak bug type. Similar to r208110/r208155. Found by LSan.
llvm-svn: 208251
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
index 5a505fcef84..5c4b993f5b6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
@@ -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(ImplicitNullDerefEvent event) const {
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);
}
OpenPOWER on IntegriCloud