| Daniel Dunbar | a45cf5b | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -analyze -checker-cfref -verify %s && |
| 2 | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s |
| Ted Kremenek | fe32cc0 | 2009-01-21 06:57:53 +0000 | [diff] [blame] | 3 | |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 4 | |
| 5 | //===----------------------------------------------------------------------===// |
| 6 | // The following code is reduced using delta-debugging from |
| 7 | // Foundation.h (Mac OS X). |
| 8 | // |
| 9 | // It includes the basic definitions for the test cases below. |
| 10 | // Not including Foundation.h directly makes this test case both svelte and |
| 11 | // portable to non-Mac platforms. |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | typedef unsigned int __darwin_natural_t; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 15 | typedef unsigned int UInt32; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 16 | typedef signed long CFIndex; |
| 17 | typedef const void * CFTypeRef; |
| 18 | typedef const struct __CFString * CFStringRef; |
| 19 | typedef const struct __CFAllocator * CFAllocatorRef; |
| 20 | extern const CFAllocatorRef kCFAllocatorDefault; |
| 21 | extern CFTypeRef CFRetain(CFTypeRef cf); |
| 22 | extern void CFRelease(CFTypeRef cf); |
| 23 | typedef struct { |
| 24 | } |
| 25 | CFArrayCallBacks; |
| 26 | extern const CFArrayCallBacks kCFTypeArrayCallBacks; |
| 27 | typedef const struct __CFArray * CFArrayRef; |
| 28 | typedef struct __CFArray * CFMutableArrayRef; |
| 29 | extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks); |
| 30 | extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx); |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 31 | extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 32 | typedef const struct __CFDictionary * CFDictionaryRef; |
| 33 | typedef UInt32 CFStringEncoding; |
| 34 | enum { |
| 35 | kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 }; |
| 36 | extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding); |
| 37 | typedef double CFTimeInterval; |
| 38 | typedef CFTimeInterval CFAbsoluteTime; |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 39 | extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 40 | typedef const struct __CFDate * CFDateRef; |
| 41 | extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); |
| 42 | extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); |
| 43 | typedef __darwin_natural_t natural_t; |
| 44 | typedef natural_t mach_port_name_t; |
| 45 | typedef mach_port_name_t mach_port_t; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 46 | typedef int kern_return_t; |
| 47 | typedef kern_return_t mach_error_t; |
| 48 | typedef struct objc_selector *SEL; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 49 | typedef signed char BOOL; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 50 | typedef unsigned long NSUInteger; |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 51 | @class NSString, Protocol; |
| 52 | extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 53 | typedef struct _NSZone NSZone; |
| 54 | @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; |
| 55 | @protocol NSObject - (BOOL)isEqual:(id)object; |
| 56 | - (id)retain; |
| 57 | - (oneway void)release; |
| Ted Kremenek | f675864 | 2009-01-28 21:20:48 +0000 | [diff] [blame] | 58 | - (id)autorelease; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 59 | @end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone; |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 60 | @end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 61 | @end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 62 | @end @interface NSObject <NSObject> { |
| 63 | } |
| Ted Kremenek | 340fd2d | 2009-03-13 20:27:06 +0000 | [diff] [blame] | 64 | + (id)allocWithZone:(NSZone *)zone; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 65 | + (id)alloc; |
| 66 | - (void)dealloc; |
| 67 | @end extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); |
| 68 | typedef struct { |
| 69 | } |
| 70 | NSFastEnumerationState; |
| 71 | @protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; |
| 72 | @end @class NSString, NSDictionary; |
| 73 | typedef double NSTimeInterval; |
| 74 | @interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; |
| 75 | @end typedef unsigned short unichar; |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 76 | @interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 77 | - ( const char *)UTF8String; |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 78 | - (id)initWithUTF8String:(const char *)nullTerminatedCString; |
| 79 | + (id)stringWithUTF8String:(const char *)nullTerminatedCString; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 80 | @end @class NSDictionary; |
| 81 | @interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count; |
| 82 | @end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; |
| 83 | - (void)setObject:(id)anObject forKey:(id)aKey; |
| 84 | @end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems; |
| 85 | @end @class NSString, NSDictionary, NSArray; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 86 | typedef mach_port_t io_object_t; |
| 87 | typedef io_object_t io_service_t; |
| 88 | typedef struct __DASession * DASessionRef; |
| 89 | extern DASessionRef DASessionCreate( CFAllocatorRef allocator ); |
| 90 | typedef struct __DADisk * DADiskRef; |
| 91 | extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name ); |
| 92 | extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media ); |
| 93 | extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk ); |
| 94 | extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk ); |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 95 | @interface NSTask : NSObject - (id)init; |
| 96 | @end extern NSString * const NSTaskDidTerminateNotification; |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 97 | @interface NSResponder : NSObject <NSCoding> { |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 98 | struct __vaFlags { |
| 99 | } |
| 100 | _vaFlags; |
| 101 | } |
| 102 | @end @protocol NSAnimatablePropertyContainer - (id)animator; |
| 103 | @end extern NSString *NSAnimationTriggerOrderIn ; |
| 104 | @class NSBitmapImageRep, NSCursor, NSGraphicsContext, NSImage, NSPasteboard, NSScrollView, NSTextInputContext, NSWindow, NSAttributedString; |
| 105 | @interface NSView : NSResponder <NSAnimatablePropertyContainer> { |
| 106 | struct __VFlags2 { |
| 107 | } |
| 108 | _vFlags2; |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 109 | } |
| 110 | @end @class NSColor, NSFont, NSNotification; |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 111 | @interface NSTextTab : NSObject <NSCopying, NSCoding> { |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 112 | } |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 113 | @end @protocol NSValidatedUserInterfaceItem - (SEL)action; |
| 114 | @end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; |
| 115 | @end @class NSArray, NSError, NSImage, NSView, NSNotificationCenter, NSURL, NSScreen, NSRunningApplication; |
| 116 | @interface NSApplication : NSResponder <NSUserInterfaceValidations> { |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 117 | } |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 118 | @end enum { |
| 119 | NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; |
| 120 | typedef NSUInteger NSApplicationTerminateReply; |
| 121 | @protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; |
| 122 | @end enum { |
| 123 | NSUserInterfaceLayoutDirectionLeftToRight = 0, NSUserInterfaceLayoutDirectionRightToLeft = 1 }; |
| 124 | @interface NSManagedObject : NSObject { |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 125 | } |
| 126 | @end enum { |
| 127 | kDAReturnSuccess = 0, kDAReturnError = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C }; |
| 128 | typedef mach_error_t DAReturn; |
| 129 | typedef const struct __DADissenter * DADissenterRef; |
| 130 | extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string ); |
| 131 | |
| Ted Kremenek | 7e7ed52 | 2009-05-11 17:45:06 +0000 | [diff] [blame] | 132 | @interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> |
| 133 | - (NSUInteger)count; |
| 134 | + (id)array; |
| 135 | @end |
| 136 | |
| 137 | @interface NSAutoreleasePool : NSObject {} |
| 138 | + (void)addObject:(id)anObject; |
| 139 | - (void)addObject:(id)anObject; |
| 140 | - (void)drain; |
| 141 | @end |
| 142 | |
| Ted Kremenek | f9fa3cb | 2009-05-14 21:29:16 +0000 | [diff] [blame] | 143 | @interface NSData : NSObject {} |
| 144 | + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; |
| 145 | + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; |
| 146 | @end |
| 147 | |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 148 | //===----------------------------------------------------------------------===// |
| 149 | // Test cases. |
| 150 | //===----------------------------------------------------------------------===// |
| 151 | |
| 152 | CFAbsoluteTime f1() { |
| 153 | CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); |
| 154 | CFDateRef date = CFDateCreate(0, t); |
| 155 | CFRetain(date); |
| 156 | CFRelease(date); |
| 157 | CFDateGetAbsoluteTime(date); // no-warning |
| 158 | CFRelease(date); |
| 159 | t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}} |
| 160 | return t; |
| 161 | } |
| 162 | |
| 163 | CFAbsoluteTime f2() { |
| 164 | CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); |
| 165 | CFDateRef date = CFDateCreate(0, t); |
| 166 | [((NSDate*) date) retain]; |
| 167 | CFRelease(date); |
| 168 | CFDateGetAbsoluteTime(date); // no-warning |
| 169 | [((NSDate*) date) release]; |
| 170 | t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}} |
| 171 | return t; |
| 172 | } |
| 173 | |
| 174 | |
| 175 | NSDate* global_x; |
| 176 | |
| 177 | // Test to see if we supresss an error when we store the pointer |
| 178 | // to a global. |
| 179 | |
| 180 | CFAbsoluteTime f3() { |
| 181 | CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); |
| 182 | CFDateRef date = CFDateCreate(0, t); |
| 183 | [((NSDate*) date) retain]; |
| 184 | CFRelease(date); |
| 185 | CFDateGetAbsoluteTime(date); // no-warning |
| 186 | global_x = (NSDate*) date; |
| 187 | [((NSDate*) date) release]; |
| 188 | t = CFDateGetAbsoluteTime(date); // no-warning |
| 189 | return t; |
| 190 | } |
| 191 | |
| Ted Kremenek | fe32cc0 | 2009-01-21 06:57:53 +0000 | [diff] [blame] | 192 | //--------------------------------------------------------------------------- |
| 193 | // Test case 'f4' differs for region store and basic store. See |
| 194 | // retain-release-region-store.m and retain-release-basic-store.m. |
| 195 | //--------------------------------------------------------------------------- |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 196 | |
| 197 | // Test a leak. |
| 198 | |
| 199 | CFAbsoluteTime f5(int x) { |
| 200 | CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 201 | CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}} |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 202 | |
| 203 | if (x) |
| 204 | CFRelease(date); |
| 205 | |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 206 | return t; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | // Test a leak involving the return. |
| 210 | |
| 211 | CFDateRef f6(int x) { |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 212 | CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}} |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 213 | CFRetain(date); |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 214 | return date; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | // Test a leak involving an overwrite. |
| 218 | |
| 219 | CFDateRef f7() { |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 220 | CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}} |
| Ted Kremenek | f08ac27 | 2009-01-24 00:55:43 +0000 | [diff] [blame] | 221 | CFRetain(date); |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 222 | date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 223 | return date; |
| 224 | } |
| 225 | |
| 226 | // Generalization of Create rule. MyDateCreate returns a CFXXXTypeRef, and |
| 227 | // has the word create. |
| 228 | CFDateRef MyDateCreate(); |
| 229 | |
| 230 | CFDateRef f8() { |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 231 | CFDateRef date = MyDateCreate(); // expected-warning{{leak}} |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 232 | CFRetain(date); |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 233 | return date; |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | CFDateRef f9() { |
| 237 | CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); |
| 238 | int *p = 0; |
| Ted Kremenek | 0b891a3 | 2009-03-09 22:46:49 +0000 | [diff] [blame] | 239 | // When allocations fail, CFDateCreate can return null. |
| 240 | if (!date) *p = 1; // expected-warning{{null}} |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 241 | return date; |
| 242 | } |
| 243 | |
| 244 | // Handle DiskArbitration API: |
| 245 | // |
| 246 | // http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/ |
| 247 | // |
| 248 | void f10(io_service_t media, DADiskRef d, CFStringRef s) { |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 249 | DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}} |
| 250 | if (disk) NSLog(@"ok"); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 251 | |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 252 | disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}} |
| 253 | if (disk) NSLog(@"ok"); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 254 | |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 255 | CFDictionaryRef dict = DADiskCopyDescription(d); // expected-warning{{leak}} |
| 256 | if (dict) NSLog(@"ok"); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 257 | |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 258 | disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}} |
| 259 | if (disk) NSLog(@"ok"); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 260 | |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 261 | DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, // expected-warning{{leak}} |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 262 | kDAReturnSuccess, s); |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 263 | if (dissenter) NSLog(@"ok"); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 264 | |
| Ted Kremenek | fc5d067 | 2009-02-04 23:49:09 +0000 | [diff] [blame] | 265 | DASessionRef session = DASessionCreate(kCFAllocatorDefault); // expected-warning{{leak}} |
| 266 | if (session) NSLog(@"ok"); |
| Ted Kremenek | 7e90422 | 2009-01-12 21:45:02 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | // Test retain/release checker with CFString and CFMutableArray. |
| 270 | void f11() { |
| 271 | // Create the array. |
| 272 | CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); |
| 273 | |
| 274 | // Create a string. |
| 275 | CFStringRef s1 = CFStringCreateWithCString(0, "hello world", |
| 276 | kCFStringEncodingUTF8); |
| 277 | |
| 278 | // Add the string to the array. |
| 279 | CFArrayAppendValue(A, s1); |
| 280 | |
| 281 | // Decrement the reference count. |
| 282 | CFRelease(s1); // no-warning |
| 283 | |
| 284 | // Get the string. We don't own it. |
| 285 | s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0); |
| 286 | |
| 287 | // Release the array. |
| 288 | CFRelease(A); // no-warning |
| 289 | |
| 290 | // Release the string. This is a bug. |
| 291 | CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}} |
| 292 | } |
| 293 | |
| Ted Kremenek | 86afde3 | 2009-01-16 18:40:33 +0000 | [diff] [blame] | 294 | // PR 3337: Handle functions declared using typedefs. |
| 295 | typedef CFTypeRef CREATEFUN(); |
| 296 | CREATEFUN MyCreateFun; |
| 297 | |
| 298 | void f12() { |
| 299 | CFTypeRef o = MyCreateFun(); // expected-warning {{leak}} |
| 300 | } |
| Ted Kremenek | f675864 | 2009-01-28 21:20:48 +0000 | [diff] [blame] | 301 | |
| 302 | void f13_autorelease() { |
| Ted Kremenek | 2d0ff62 | 2009-05-09 01:50:57 +0000 | [diff] [blame] | 303 | CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning |
| Ted Kremenek | f675864 | 2009-01-28 21:20:48 +0000 | [diff] [blame] | 304 | [(id) A autorelease]; // no-warning |
| 305 | } |
| Ted Kremenek | bea465ae | 2009-02-19 18:20:28 +0000 | [diff] [blame] | 306 | |
| Ted Kremenek | 2d0ff62 | 2009-05-09 01:50:57 +0000 | [diff] [blame] | 307 | void f13_autorelease_b() { |
| 308 | CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); |
| 309 | [(id) A autorelease]; |
| Ted Kremenek | 3978f79 | 2009-05-10 05:11:21 +0000 | [diff] [blame] | 310 | [(id) A autorelease]; // expected-warning{{Object sent -autorelease too many times}} |
| Ted Kremenek | 2d0ff62 | 2009-05-09 01:50:57 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | CFMutableArrayRef f13_autorelease_c() { |
| 314 | CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); |
| 315 | [(id) A autorelease]; |
| 316 | [(id) A autorelease]; |
| Ted Kremenek | 3978f79 | 2009-05-10 05:11:21 +0000 | [diff] [blame] | 317 | return A; // expected-warning{{Object sent -autorelease too many times}} |
| Ted Kremenek | 2d0ff62 | 2009-05-09 01:50:57 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | CFMutableArrayRef f13_autorelease_d() { |
| 321 | CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); |
| 322 | [(id) A autorelease]; |
| 323 | [(id) A autorelease]; |
| Ted Kremenek | 3978f79 | 2009-05-10 05:11:21 +0000 | [diff] [blame] | 324 | CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object sent -autorelease too many times}} |
| Ted Kremenek | 2d0ff62 | 2009-05-09 01:50:57 +0000 | [diff] [blame] | 325 | CFRelease(B); // no-warning |
| 326 | } |
| 327 | |
| 328 | |
| Ted Kremenek | bea465ae | 2009-02-19 18:20:28 +0000 | [diff] [blame] | 329 | // This case exercises the logic where the leak site is the same as the allocation site. |
| 330 | void f14_leakimmediately() { |
| 331 | CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} |
| 332 | } |
| Ted Kremenek | a7ec605 | 2009-03-05 18:15:02 +0000 | [diff] [blame] | 333 | |
| Ted Kremenek | 25db1f3 | 2009-04-07 05:33:18 +0000 | [diff] [blame] | 334 | // Test that we track an allocated object beyond the point where the *name* |
| 335 | // of the variable storing the reference is no longer live. |
| 336 | void f15() { |
| 337 | // Create the array. |
| 338 | CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); |
| 339 | CFMutableArrayRef *B = &A; |
| 340 | // At this point, the name 'A' is no longer live. |
| 341 | CFRelease(*B); // no-warning |
| 342 | } |
| 343 | |
| 344 | |
| Ted Kremenek | a7ec605 | 2009-03-05 18:15:02 +0000 | [diff] [blame] | 345 | // Test basic tracking of ivars associated with 'self'. For the retain/release |
| 346 | // checker we currently do not want to flag leaks associated with stores |
| 347 | // of tracked objects to ivars. |
| 348 | @interface SelfIvarTest : NSObject { |
| 349 | id myObj; |
| 350 | } |
| 351 | - (void)test_self_tracking; |
| 352 | @end |
| 353 | |
| 354 | @implementation SelfIvarTest |
| 355 | - (void)test_self_tracking { |
| 356 | myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning |
| 357 | } |
| 358 | @end |
| 359 | |
| Ted Kremenek | dee56e3 | 2009-05-10 06:25:57 +0000 | [diff] [blame] | 360 | // Test return of non-owned objects in contexts where an owned object |
| 361 | // is expected. |
| 362 | @interface TestReturnNotOwnedWhenExpectedOwned |
| 363 | - (NSString*)newString; |
| 364 | @end |
| 365 | |
| 366 | @implementation TestReturnNotOwnedWhenExpectedOwned |
| 367 | - (NSString*)newString { |
| 368 | NSString *s = [NSString stringWithUTF8String:"hello"]; |
| 369 | return s; // expected-warning{{Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected}} |
| 370 | } |
| 371 | @end |
| 372 | |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 373 | // <rdar://problem/6659160> |
| 374 | int isFoo(char c); |
| 375 | |
| 376 | static void rdar_6659160(char *inkind, char *inname) |
| 377 | { |
| 378 | // We currently expect that [NSObject alloc] cannot fail. This |
| 379 | // will be a toggled flag in the future. It can indeed return null, but |
| 380 | // Cocoa programmers generally aren't expected to reason about out-of-memory |
| 381 | // conditions. |
| 382 | NSString *kind = [[NSString alloc] initWithUTF8String:inkind]; // expected-warning{{leak}} |
| 383 | |
| 384 | // We do allow stringWithUTF8String to fail. This isn't really correct, as |
| Ted Kremenek | b294d19 | 2009-03-23 17:10:25 +0000 | [diff] [blame] | 385 | // far as returning 0. In most error conditions it will throw an exception. |
| 386 | // If allocation fails it could return 0, but again this |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 387 | // isn't expected. |
| 388 | NSString *name = [NSString stringWithUTF8String:inname]; |
| 389 | if(!name) |
| 390 | return; |
| 391 | |
| 392 | const char *kindC = 0; |
| 393 | const char *nameC = 0; |
| 394 | |
| 395 | // In both cases, we cannot reach a point down below where we |
| 396 | // dereference kindC or nameC with either being null. This is because |
| 397 | // we assume that [NSObject alloc] doesn't fail and that we have the guard |
| 398 | // up above. |
| 399 | |
| 400 | if(kind) |
| 401 | kindC = [kind UTF8String]; |
| 402 | if(name) |
| 403 | nameC = [name UTF8String]; |
| Ted Kremenek | 0b891a3 | 2009-03-09 22:46:49 +0000 | [diff] [blame] | 404 | if(!isFoo(kindC[0])) // expected-warning{{null}} |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 405 | return; |
| 406 | if(!isFoo(nameC[0])) // no-warning |
| 407 | return; |
| 408 | |
| 409 | [kind release]; |
| Ted Kremenek | 0a1f9c4 | 2009-04-23 21:25:57 +0000 | [diff] [blame] | 410 | [name release]; // expected-warning{{Incorrect decrement of the reference count}} |
| Ted Kremenek | 3987bbe | 2009-03-09 22:28:18 +0000 | [diff] [blame] | 411 | } |
| Ted Kremenek | a7ec605 | 2009-03-05 18:15:02 +0000 | [diff] [blame] | 412 | |
| Ted Kremenek | 340fd2d | 2009-03-13 20:27:06 +0000 | [diff] [blame] | 413 | // PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming |
| 414 | // conventions with respect to 'return'ing ownership. |
| 415 | @interface PR3677: NSObject @end |
| 416 | @implementation PR3677 |
| 417 | + (id)allocWithZone:(NSZone *)inZone { |
| 418 | return [super allocWithZone:inZone]; // no-warning |
| 419 | } |
| 420 | @end |
| 421 | |
| Ted Kremenek | 67a3bb7 | 2009-03-19 19:50:58 +0000 | [diff] [blame] | 422 | // PR 3820 - Reason about calls to -dealloc |
| 423 | void pr3820_DeallocInsteadOfRelease(void) |
| 424 | { |
| 425 | id foo = [[NSString alloc] init]; // no-warning |
| 426 | [foo dealloc]; |
| 427 | // foo is not leaked, since it has been deallocated. |
| 428 | } |
| 429 | |
| 430 | void pr3820_ReleaseAfterDealloc(void) |
| 431 | { |
| 432 | id foo = [[NSString alloc] init]; |
| 433 | [foo dealloc]; |
| 434 | [foo release]; // expected-warning{{used after it is release}} |
| 435 | // NSInternalInconsistencyException: message sent to deallocated object |
| 436 | } |
| 437 | |
| 438 | void pr3820_DeallocAfterRelease(void) |
| 439 | { |
| 440 | NSLog(@"\n\n[%s]", __FUNCTION__); |
| 441 | id foo = [[NSString alloc] init]; |
| 442 | [foo release]; |
| 443 | [foo dealloc]; // expected-warning{{used after it is released}} |
| 444 | // message sent to released object |
| 445 | } |
| Ted Kremenek | b294d19 | 2009-03-23 17:10:25 +0000 | [diff] [blame] | 446 | |
| 447 | // From <rdar://problem/6704930>. The problem here is that 'length' binds to |
| 448 | // '($0 - 1)' after '--length', but SimpleConstraintManager doesn't know how to |
| 449 | // reason about '($0 - 1) > constant'. As a temporary hack, we drop the value |
| 450 | // of '($0 - 1)' and conjure a new symbol. |
| 451 | void rdar6704930(unsigned char *s, unsigned int length) { |
| 452 | NSString* name = 0; |
| 453 | if (s != 0) { |
| 454 | if (length > 0) { |
| 455 | while (length > 0) { |
| 456 | if (*s == ':') { |
| 457 | ++s; |
| 458 | --length; |
| 459 | name = [[NSString alloc] init]; // no-warning |
| 460 | break; |
| 461 | } |
| 462 | ++s; |
| 463 | --length; |
| 464 | } |
| 465 | if ((length == 0) && (name != 0)) { |
| 466 | [name release]; |
| 467 | name = 0; |
| 468 | } |
| 469 | if (length == 0) { // no ':' found -> use it all as name |
| 470 | name = [[NSString alloc] init]; // no-warning |
| 471 | } |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | if (name != 0) { |
| 476 | [name release]; |
| 477 | } |
| 478 | } |
| 479 | |
| Ted Kremenek | 44e662c | 2009-04-24 23:09:54 +0000 | [diff] [blame] | 480 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 481 | // <rdar://problem/6833332> |
| 482 | // One build of the analyzer accidentally stopped tracking the allocated |
| 483 | // object after the 'retain'. |
| Ted Kremenek | d0e3ab2 | 2009-05-11 18:30:24 +0000 | [diff] [blame] | 484 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | ebc6d91 | 2009-04-29 00:41:31 +0000 | [diff] [blame] | 485 | |
| 486 | @interface rdar_6833332 : NSObject <NSApplicationDelegate> { |
| 487 | NSWindow *window; |
| 488 | } |
| 489 | @property (nonatomic, retain) NSWindow *window; |
| 490 | @end |
| 491 | |
| 492 | @implementation rdar_6833332 |
| 493 | @synthesize window; |
| 494 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { |
| 495 | NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} |
| 496 | |
| 497 | [dict setObject:@"foo" forKey:@"bar"]; |
| 498 | |
| 499 | NSLog(@"%@", dict); |
| 500 | } |
| 501 | - (void)dealloc { |
| 502 | [window release]; |
| 503 | [super dealloc]; |
| 504 | } |
| 505 | @end |
| 506 | |
| Ted Kremenek | d73cfc7 | 2009-05-09 03:10:32 +0000 | [diff] [blame] | 507 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | 7e7ed52 | 2009-05-11 17:45:06 +0000 | [diff] [blame] | 508 | // <rdar://problem/6257780> clang checker fails to catch use-after-release |
| 509 | //===----------------------------------------------------------------------===// |
| 510 | |
| Ted Kremenek | d0e3ab2 | 2009-05-11 18:30:24 +0000 | [diff] [blame] | 511 | int rdar_6257780_Case1() { |
| Ted Kremenek | 7e7ed52 | 2009-05-11 17:45:06 +0000 | [diff] [blame] | 512 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; |
| 513 | NSArray *array = [NSArray array]; |
| 514 | [array release]; // expected-warning{{Incorrect decrement of the reference count of an object is not owned at this point by the caller}} |
| 515 | [pool drain]; |
| 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | d0e3ab2 | 2009-05-11 18:30:24 +0000 | [diff] [blame] | 520 | // <rdar://problem/6866843> Checker should understand new/setObject:/release constructs |
| 521 | //===----------------------------------------------------------------------===// |
| 522 | |
| 523 | void rdar_6866843() { |
| 524 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; |
| 525 | NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; |
| 526 | NSArray* array = [[NSArray alloc] init]; |
| 527 | [dictionary setObject:array forKey:@"key"]; |
| 528 | [array release]; |
| 529 | // Using 'array' here should be fine |
| 530 | NSLog(@"array = %@\n", array); // no-warning |
| 531 | // Now the array is released |
| 532 | [dictionary release]; |
| 533 | [pool drain]; |
| 534 | } |
| 535 | |
| Ted Kremenek | 95d1819 | 2009-05-12 04:53:03 +0000 | [diff] [blame] | 536 | |
| 537 | //===----------------------------------------------------------------------===// |
| 538 | // <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects |
| 539 | //===----------------------------------------------------------------------===// |
| 540 | |
| 541 | typedef CFTypeRef OtherRef; |
| 542 | |
| 543 | @interface RDar6877235 : NSObject {} |
| 544 | - (CFTypeRef)_copyCFTypeRef; |
| 545 | - (OtherRef)_copyOtherRef; |
| 546 | @end |
| 547 | |
| 548 | @implementation RDar6877235 |
| 549 | - (CFTypeRef)_copyCFTypeRef { |
| 550 | return [[NSString alloc] init]; // no-warning |
| 551 | } |
| 552 | - (OtherRef)_copyOtherRef { |
| 553 | return [[NSString alloc] init]; // no-warning |
| 554 | } |
| 555 | @end |
| 556 | |
| Ted Kremenek | d0e3ab2 | 2009-05-11 18:30:24 +0000 | [diff] [blame] | 557 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | 1272f70 | 2009-05-12 20:06:54 +0000 | [diff] [blame] | 558 | //<rdar://problem/6320065> false positive - init method returns an object owned by caller |
| 559 | //===----------------------------------------------------------------------===// |
| 560 | |
| 561 | @interface RDar6320065 : NSObject { |
| 562 | NSString *_foo; |
| 563 | } |
| 564 | - (id)initReturningNewClass; |
| 565 | - (id)initReturningNewClassBad; |
| 566 | - (id)initReturningNewClassBad2; |
| 567 | @end |
| 568 | |
| 569 | @interface RDar6320065Subclass : RDar6320065 |
| 570 | @end |
| 571 | |
| 572 | @implementation RDar6320065 |
| 573 | - (id)initReturningNewClass { |
| 574 | [self release]; |
| 575 | self = [[RDar6320065Subclass alloc] init]; // no-warning |
| 576 | return self; |
| 577 | } |
| 578 | - (id)initReturningNewClassBad { |
| 579 | [self release]; |
| 580 | [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}} |
| 581 | return self; |
| 582 | } |
| 583 | - (id)initReturningNewClassBad2 { |
| 584 | [self release]; |
| 585 | self = [[RDar6320065Subclass alloc] init]; |
| 586 | return [self autorelease]; // expected-warning{{Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected}} |
| 587 | } |
| 588 | |
| 589 | @end |
| 590 | |
| 591 | @implementation RDar6320065Subclass |
| 592 | @end |
| 593 | |
| 594 | int RDar6320065_test() { |
| 595 | RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning |
| 596 | [test release]; |
| 597 | return 0; |
| 598 | } |
| 599 | |
| 600 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | f9fa3cb | 2009-05-14 21:29:16 +0000 | [diff] [blame] | 601 | // <rdar://problem/6859457> [NSData dataWithBytesNoCopy] does not return a retained object |
| 602 | //===----------------------------------------------------------------------===// |
| 603 | |
| 604 | @interface RDar6859457 : NSObject {} |
| 605 | - (NSString*) NoCopyString; |
| 606 | - (NSString*) noCopyString; |
| 607 | @end |
| 608 | |
| 609 | @implementation RDar6859457 |
| 610 | - (NSString*) NoCopyString { return [[NSString alloc] init]; } // no-warning |
| 611 | - (NSString*) noCopyString { return [[NSString alloc] init]; } // no-warning |
| 612 | @end |
| 613 | |
| 614 | void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) { |
| 615 | [x NoCopyString]; // expected-warning{{leak}} |
| 616 | [x noCopyString]; // expected-warning{{leak}} |
| 617 | [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning |
| 618 | [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning |
| 619 | } |
| 620 | |
| 621 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | 3281977 | 2009-05-15 15:49:00 +0000 | [diff] [blame^] | 622 | // Method name that has a null IdentifierInfo* for its first selector slot. |
| 623 | // This test just makes sure that we handle it. |
| 624 | //===----------------------------------------------------------------------===// |
| 625 | |
| 626 | @interface TestNullIdentifier |
| 627 | @end |
| 628 | |
| 629 | @implementation TestNullIdentifier |
| 630 | + (id):(int)x, ... { |
| 631 | return [[NSString alloc] init]; // expected-warning{{leak}} |
| 632 | } |
| 633 | |
| 634 | //===----------------------------------------------------------------------===// |
| Ted Kremenek | d73cfc7 | 2009-05-09 03:10:32 +0000 | [diff] [blame] | 635 | // Tests of ownership attributes. |
| 636 | //===----------------------------------------------------------------------===// |
| 637 | |
| Ted Kremenek | 3b204e4 | 2009-05-13 21:07:32 +0000 | [diff] [blame] | 638 | typedef NSString* MyStringTy; |
| 639 | |
| Ted Kremenek | d73cfc7 | 2009-05-09 03:10:32 +0000 | [diff] [blame] | 640 | @interface TestOwnershipAttr : NSObject |
| Ted Kremenek | 3b204e4 | 2009-05-13 21:07:32 +0000 | [diff] [blame] | 641 | - (NSString*) returnsAnOwnedString __attribute__((ns_returns_retained)); // no-warning |
| 642 | - (NSString*) returnsAnOwnedCFString __attribute__((cf_returns_retained)); // no-warning |
| 643 | - (MyStringTy) returnsAnOwnedTypedString __attribute__((ns_returns_retained)); // no-warning |
| 644 | - (int) returnsAnOwnedInt __attribute__((ns_returns_retained)); // expected-warning{{'ns_returns_retained' attribute only applies to functions or methods that return a pointer or Objective-C object}} |
| Ted Kremenek | d73cfc7 | 2009-05-09 03:10:32 +0000 | [diff] [blame] | 645 | @end |
| 646 | |
| Ted Kremenek | 3b204e4 | 2009-05-13 21:07:32 +0000 | [diff] [blame] | 647 | static int ownership_attribute_doesnt_go_here __attribute__((ns_returns_retained)); // expected-warning{{'ns_returns_retained' attribute only applies to function or method types}} |
| 648 | |
| Ted Kremenek | d73cfc7 | 2009-05-09 03:10:32 +0000 | [diff] [blame] | 649 | void test_attr_1(TestOwnershipAttr *X) { |
| 650 | NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}} |
| 651 | } |
| 652 | |
| 653 | void test_attr_1b(TestOwnershipAttr *X) { |
| 654 | NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} |
| 655 | } |
| 656 | |