Changeset 237365 in webkit


Ignore:
Timestamp:
Oct 23, 2018 1:36:37 PM (6 years ago)
Author:
ddkilzer@apple.com
Message:

Fix false positive leaks when using custom -init methods that don't start with -init
<https://webkit.org/b/190818>
<rdar://problem/45476042>

Reviewed by Dan Bernstein.

Source/WebKit:

  • UIProcess/Cocoa/WKWebViewContentProvider.h:

(-[WKWebViewContentProvider web_initWithFrame:webView:mimeType:]):
Add attribute to make this behave like an -init method.

Source/WebKitLegacy/mac:

  • Misc/WebKitErrors.m: Move descriptions static global so that

it is accessible by both categories.
(-[NSError _webkit_initWithDomain:code:URL:]): Declare new
NSError (WebKitInternal) category. Add attribute to make this
behave like an -init method.
(-[NSError _webkit_initWithDomain:code:URL:]): Move into new
NSError (WebKitInternal) category. Modernize method. Replace
constant NSString with NSURLErrorFailingURLStringErrorKey.

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r237355 r237365  
     12018-10-23  David Kilzer  <ddkilzer@apple.com>
     2
     3        Fix false positive leaks when using custom -init methods that don't start with -init
     4        <https://webkit.org/b/190818>
     5        <rdar://problem/45476042>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        * UIProcess/Cocoa/WKWebViewContentProvider.h:
     10        (-[WKWebViewContentProvider web_initWithFrame:webView:mimeType:]):
     11        Add attribute to make this behave like an -init method.
     12
    1132018-10-23  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h

    r237266 r237365  
    4444@protocol WKWebViewContentProvider <NSObject>
    4545
    46 - (instancetype)web_initWithFrame:(CGRect) frame webView:(WKWebView *)webView mimeType:(NSString *)mimeType;
     46- (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView mimeType:(NSString *)mimeType __attribute__((objc_method_family(init)));
    4747- (void)web_setContentProviderData:(NSData *)data suggestedFilename:(NSString *)filename;
    4848- (void)web_setMinimumSize:(CGSize)size;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r237266 r237365  
     12018-10-23  David Kilzer  <ddkilzer@apple.com>
     2
     3        Fix false positive leaks when using custom -init methods that don't start with -init
     4        <https://webkit.org/b/190818>
     5        <rdar://problem/45476042>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        * Misc/WebKitErrors.m: Move `descriptions` static global so that
     10        it is accessible by both categories.
     11        (-[NSError _webkit_initWithDomain:code:URL:]): Declare new
     12        NSError (WebKitInternal) category.  Add attribute to make this
     13        behave like an -init method.
     14        (-[NSError _webkit_initWithDomain:code:URL:]): Move into new
     15        NSError (WebKitInternal) category.  Modernize method.  Replace
     16        constant NSString with `NSURLErrorFailingURLStringErrorKey`.
     17
    1182018-10-18  Alexey Proskuryakov  <ap@apple.com>
    219
  • trunk/Source/WebKitLegacy/mac/Misc/WebKitErrors.m

    r232452 r237365  
    3030
    3131#import "WebLocalizableStringsInternal.h"
     32#import <Foundation/NSURLError.h>
    3233#import <WebKitLegacy/WebKitErrorsPrivate.h>
    3334#import <WebKitLegacy/WebNSURLExtras.h>
     
    5960#define WebKitErrorDescriptionGeolocationLocationUnknown UI_STRING_INTERNAL("The current location cannot be found.", "WebKitErrorGeolocationLocationUnknown description")
    6061
     62static NSMutableDictionary *descriptions = nil;
     63
     64@interface NSError (WebKitInternal)
     65- (instancetype)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL __attribute__((objc_method_family(init)));
     66@end
     67
     68@implementation NSError (WebKitInternal)
     69
     70- (instancetype)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL
     71{
     72    // Insert a localized string here for those folks not savvy to our category methods.
     73    NSDictionary *descriptionsDict = [descriptions objectForKey:domain];
     74    NSString *localizedDescription = descriptionsDict ? [descriptionsDict objectForKey:[NSNumber numberWithInt:code]] : nil;
     75    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
     76        URL, @"NSErrorFailingURLKey",
     77        [URL absoluteString], NSURLErrorFailingURLStringErrorKey,
     78        localizedDescription, NSLocalizedDescriptionKey,
     79        nil];
     80    return [self initWithDomain:domain code:code userInfo:dict];
     81}
     82
     83@end
     84
    6185@implementation NSError (WebKitExtras)
    62 
    63 static NSMutableDictionary *descriptions = nil;
    6486
    6587+ (void)_registerWebKitErrors
     
    90112        }
    91113    });
    92 }
    93 
    94 -(id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL
    95 {
    96     NSDictionary *descriptionsDict;
    97     NSString *localizedDesc;
    98     NSDictionary *dict;
    99     // insert a localized string here for those folks not savvy to our category methods
    100     descriptionsDict = [descriptions objectForKey:domain];
    101     localizedDesc = descriptionsDict ? [descriptionsDict objectForKey:[NSNumber numberWithInt:code]] : nil;
    102     dict = [NSDictionary dictionaryWithObjectsAndKeys:
    103         URL, @"NSErrorFailingURLKey",
    104         [URL absoluteString], @"NSErrorFailingURLStringKey",
    105         localizedDesc, NSLocalizedDescriptionKey,
    106         nil];
    107     return [self initWithDomain:domain code:code userInfo:dict];
    108114}
    109115
Note: See TracChangeset for help on using the changeset viewer.