Bug 190818 - Fix false positive leaks when using custom -init methods that don't start with -init
Summary: Fix false positive leaks when using custom -init methods that don't start wit...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-10-22 21:17 PDT by David Kilzer (:ddkilzer)
Modified: 2018-10-23 13:36 PDT (History)
3 users (show)

See Also:


Attachments
Patch v1 (3.81 KB, patch)
2018-10-22 21:24 PDT, David Kilzer (:ddkilzer)
mitz: review+
ddkilzer: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>