Changeset 218760 in webkit


Ignore:
Timestamp:
Jun 23, 2017 1:45:46 PM (7 years ago)
Author:
ddkilzer@apple.com
Message:

v3: REGRESSION (r218419): 3 NSMutableDictionary leaks calling -[WKProcessPool _pluginLoadClientPolicies]
<https://webkit.org/b/173689>

Reviewed by Tim Horton.

  • UIProcess/API/Cocoa/WKProcessPool.mm:

(policiesHashMapToDictionary): Use adoptNS().get() to avoid
dumping objects into autoreleasepools unnecessarily.

  • UIProcess/API/Cocoa/WKProcessPoolPrivate.h:

(-[WKProcessPool _pluginLoadClientPolicies]): Add back 'copy'
attribute to document that we're returning a new object on each
invocation. I shouldn't have removed it in the v2 patch.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r218759 r218760  
     12017-06-23  David Kilzer  <ddkilzer@apple.com>
     2
     3        v3: REGRESSION (r218419): 3 NSMutableDictionary leaks calling -[WKProcessPool _pluginLoadClientPolicies]
     4        <https://webkit.org/b/173689>
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/API/Cocoa/WKProcessPool.mm:
     9        (policiesHashMapToDictionary): Use adoptNS().get() to avoid
     10        dumping objects into autoreleasepools unnecessarily.
     11        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
     12        (-[WKProcessPool _pluginLoadClientPolicies]): Add back 'copy'
     13        attribute to document that we're returning a new object on each
     14        invocation.  I shouldn't have removed it in the v2 patch.
     15
    1162017-06-23  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm

    r218704 r218760  
    11/*
    2  * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    314314static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<String, HashMap<String, uint8_t>>>& map)
    315315{
    316     NSMutableDictionary *policies = [NSMutableDictionary dictionaryWithCapacity:map.size()];
     316    auto policies = adoptNS([[NSMutableDictionary alloc] initWithCapacity:map.size()]);
    317317    for (auto& hostPair : map) {
    318318        NSString *host = hostPair.key;
    319         policies[host] = [NSMutableDictionary dictionaryWithCapacity:hostPair.value.size()];
     319        policies.get()[host] = adoptNS([[NSMutableDictionary alloc] initWithCapacity:hostPair.value.size()]).get();
    320320        for (auto& bundleIdentifierPair : hostPair.value) {
    321321            NSString *bundlerIdentifier = bundleIdentifierPair.key;
    322             policies[host][bundlerIdentifier] = [NSMutableDictionary dictionaryWithCapacity:bundleIdentifierPair.value.size()];
     322            policies.get()[host][bundlerIdentifier] = adoptNS([[NSMutableDictionary alloc] initWithCapacity:bundleIdentifierPair.value.size()]).get();
    323323            for (auto& versionPair : bundleIdentifierPair.value) {
    324324                NSString *version = versionPair.key;
    325                 policies[host][bundlerIdentifier][version] = [NSNumber numberWithUnsignedInt:versionPair.value];
     325                policies.get()[host][bundlerIdentifier][version] = adoptNS([[NSNumber alloc] initWithUnsignedInt:versionPair.value]).get();
    326326            }
    327327        }
    328328    }
    329     return policies;
     329    return policies.autorelease();
    330330}
    331331
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h

    r218704 r218760  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5555#if !TARGET_OS_IPHONE
    5656- (void)_resetPluginLoadClientPolicies:(NSDictionary *)policies WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    57 @property (nonatomic, readonly) NSDictionary *_pluginLoadClientPolicies WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     57@property (nonatomic, readonly, copy) NSDictionary *_pluginLoadClientPolicies WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    5858#endif
    5959
Note: See TracChangeset for help on using the changeset viewer.