Bug 190818

Summary: Fix false positive leaks when using custom -init methods that don't start with -init
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebKit Misc.Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: joepeck, mitz, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch v1 mitz: review+, ddkilzer: commit-queue-

Description David Kilzer (:ddkilzer) 2018-10-22 21:17:05 PDT
Fix false positive leaks when using custom -init methods that don't start with -init.

<rdar://problem/45476042>
Comment 1 David Kilzer (:ddkilzer) 2018-10-22 21:24:48 PDT
Created attachment 352953 [details]
Patch v1
Comment 2 mitz 2018-10-23 10:25:04 PDT
Comment on attachment 352953 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=352953&action=review

> Source/WebKitLegacy/mac/Misc/WebKitErrorsPrivate.h:65
> +- (id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL __attribute__((objc_method_family(init)));

Can you add this declaration to a class extension in the .m file instead of the private @interface in the header file? There’s no reason to expose this internal detail in a header.
Comment 3 David Kilzer (:ddkilzer) 2018-10-23 12:18:06 PDT
Comment on attachment 352953 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=352953&action=review

>> Source/WebKitLegacy/mac/Misc/WebKitErrorsPrivate.h:65
>> +- (id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL __attribute__((objc_method_family(init)));
> 
> Can you add this declaration to a class extension in the .m file instead of the private @interface in the header file? There’s no reason to expose this internal detail in a header.

Will do.  The reason I didn't is that adding this to the WebKitErrors.m file complained about declaring the category twice:

@interface NSError (WebKitExtras)
- (id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL __attribute__((objc_method_family(init)));
@end

I can always do this instead:

@interface NSError ()
- (id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL __attribute__((objc_method_family(init)));
@end

But my OCD didn't want to leave the method implemented inside:

@implementation NSError (WebKitExtras)
@end

I guess I'll just add a separate implementation category.
Comment 4 David Kilzer (:ddkilzer) 2018-10-23 13:36:53 PDT
Committed r237365: <https://trac.webkit.org/changeset/237365>