[PATCH] D50012: [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 30 14:44:42 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC338312: [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D50012?vs=158069&id=158082#toc
Repository:
rC Clang
https://reviews.llvm.org/D50012
Files:
lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
Index: test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
===================================================================
--- test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
+++ test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
@@ -43,7 +43,7 @@
NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough.
(void) object;
(void) object2;
- [[NSRunLoop mainRunLoop] run];
+ [[NSRunLoop mainRunLoop] run];
}
}
@@ -61,6 +61,15 @@
}
}
+void no_crash_on_empty_children() {
+ @autoreleasepool {
+ for (;;) {}
+ NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
+ [[NSRunLoop mainRunLoop] run];
+ (void) object;
+ }
+}
+
#endif
#ifdef AP1
Index: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
@@ -46,8 +46,7 @@
const char * OtherMsgBind = "OtherMessageSentM";
const char * AutoreleasePoolBind = "AutoreleasePoolM";
-class RunLoopAutoreleaseLeakChecker : public Checker<
- check::ASTCodeBody> {
+class RunLoopAutoreleaseLeakChecker : public Checker<check::ASTCodeBody> {
public:
void checkASTCodeBody(const Decl *D,
@@ -66,6 +65,8 @@
seenBeforeRec(const Stmt *Parent, const Stmt *A, const Stmt *B,
MemoizationMapTy &Memoization) {
for (const Stmt *C : Parent->children()) {
+ if (!C) continue;
+
if (C == A)
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50012.158082.patch
Type: text/x-patch
Size: 1803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180730/655edd66/attachment-0001.bin>
More information about the cfe-commits
mailing list