return false;
}
+ // If the first selector starts with addPointer, insertPointer,
+ // or replacePointer, assume we are dealing with NSPointerArray or similar.
+ // This is similar to C++ containers (vector); we still might want to check
+ // that the pointers get freed, by following the container itself.
+ if (S.getNameForSlot(0).startswith("addPointer") ||
+ S.getNameForSlot(0).startswith("insertPointer") ||
+ S.getNameForSlot(0).startswith("replacePointer")) {
+ return false;
+ }
+
// If the call has a callback as an argument, assume the memory
// can be freed.
if (Call->hasNonZeroCallbackArg())
void testCallWithBlockCallbackInSystem() {
void *l = malloc(12);
SystemHeaderFunctionWithBlockParam(l, ^(void *i) { free(i); }, sizeof(char *));
+}
+
+// Test escape into NSPointerArray. radar://11691035, PR13140
+void foo(NSPointerArray* pointerArray) {
+
+ void* p1 = malloc (1024);
+ if (p1) {
+ [pointerArray addPointer:p1];
+ }
+
+ void* p2 = malloc (1024);
+ if (p2) {
+ [pointerArray insertPointer:p2 atIndex:1];
+ }
+
+ void* p3 = malloc (1024);
+ if (p3) {
+ [pointerArray replacePointerAtIndex:1 withPointer:p3];
+ }
+
+ // Freeing the buffer is allowed.
+ void* buffer = [pointerArray pointerAtIndex:0];
+ free(buffer);
}
\ No newline at end of file
extern void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString);
void SystemHeaderFunctionWithBlockParam(void *, void (^block)(void *), unsigned);
+
+@interface NSPointerArray : NSObject <NSFastEnumeration, NSCopying, NSCoding>
+- (void)addPointer:(void *)pointer;
+- (void)insertPointer:(void *)item atIndex:(NSUInteger)index;
+- (void)replacePointerAtIndex:(NSUInteger)index withPointer:(void *)item;
+- (void *)pointerAtIndex:(NSUInteger)index;
+@end
+