Changeset 218719 in webkit


Ignore:
Timestamp:
Jun 22, 2017 2:36:02 PM (7 years ago)
Author:
ddkilzer@apple.com
Message:

REGRESSION (r218419): 7 leaks in PluginLoadClientPolicies.mm
<https://webkit.org/b/173721>

Reviewed by Joseph Pecoraro.

Use RetainPtr<> to create NSMutableDictionary and NSNumber
objects to fix leaks and to avoid the autoreleasepool.

  • TestWebKitAPI/Tests/WebKit2Cocoa/PluginLoadClientPolicies.mm:

(TEST):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r218702 r218719  
     12017-06-22  David Kilzer  <ddkilzer@apple.com>
     2
     3        REGRESSION (r218419): 7 leaks in PluginLoadClientPolicies.mm
     4        <https://webkit.org/b/173721>
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Use RetainPtr<> to create NSMutableDictionary and NSNumber
     9        objects to fix leaks and to avoid the autoreleasepool.
     10
     11        * TestWebKitAPI/Tests/WebKit2Cocoa/PluginLoadClientPolicies.mm:
     12        (TEST):
     13
    1142017-06-22  Matt Lewis  <jlewis3@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PluginLoadClientPolicies.mm

    r218419 r218719  
    3333#import <WebKit/WKPluginInformation.h>
    3434#import <WebKit/WKProcessPoolPrivate.h>
     35#import <wtf/RetainPtr.h>
    3536
    3637#if WK_API_ENABLED
     
    6869    EXPECT_EQ(kWKPluginLoadClientPolicyAllow, [policiesForAppleHost[@"com.microsoft.SilverlightPlugin"][@"5.1.50901.0"] unsignedIntegerValue]);
    6970   
    70     NSMutableDictionary *newPolicies = [policies mutableCopy];
    71     [newPolicies removeObjectForKey:@"apple.com"];
    72     newPolicies[@"google.com"] = [[NSMutableDictionary alloc] init];
    73     newPolicies[@"google.com"][@"com.macromedia.Flash Player.plugin"] = [[NSMutableDictionary alloc] init];
    74     newPolicies[@"google.com"][@"com.macromedia.Flash Player.plugin"][@"26.0.0.126"] = [[NSNumber alloc] initWithUnsignedInt:kWKPluginLoadClientPolicyAllowAlways];
    75     newPolicies[@"google.com"][@"com.apple.QuickTime.plugin"] = [[NSMutableDictionary alloc] init];
    76     newPolicies[@"google.com"][@"com.apple.QuickTime.plugin"][@"1.0"] = [[NSNumber alloc] initWithUnsignedInt:kWKPluginLoadClientPolicyBlock];
    77     newPolicies[@"google.com"][@"com.apple.QuickTime.plugin"][@"1.1"] = [[NSNumber alloc] initWithUnsignedInt:kWKPluginLoadClientPolicyAllow];
     71    RetainPtr<NSMutableDictionary> newPolicies = adoptNS([policies mutableCopy]);
     72    [newPolicies.get() removeObjectForKey:@"apple.com"];
     73    newPolicies.get()[@"google.com"] = adoptNS([[NSMutableDictionary alloc] initWithCapacity:2]).get();
     74    newPolicies.get()[@"google.com"][@"com.macromedia.Flash Player.plugin"] = adoptNS([[NSMutableDictionary alloc] initWithCapacity:1]).get();
     75    newPolicies.get()[@"google.com"][@"com.macromedia.Flash Player.plugin"][@"26.0.0.126"] = adoptNS([[NSNumber alloc] initWithUnsignedInt:kWKPluginLoadClientPolicyAllowAlways]).get();
     76    newPolicies.get()[@"google.com"][@"com.apple.QuickTime.plugin"] = adoptNS([[NSMutableDictionary alloc] initWithCapacity:2]).get();
     77    newPolicies.get()[@"google.com"][@"com.apple.QuickTime.plugin"][@"1.0"] = adoptNS([[NSNumber alloc] initWithUnsignedInt:kWKPluginLoadClientPolicyBlock]).get();
     78    newPolicies.get()[@"google.com"][@"com.apple.QuickTime.plugin"][@"1.1"] = adoptNS([[NSNumber alloc] initWithUnsignedInt:kWKPluginLoadClientPolicyAllow]).get();
    7879   
    79     [processPool.get() _resetPluginLoadClientPolicies:newPolicies];
     80    [processPool.get() _resetPluginLoadClientPolicies:newPolicies.get()];
    8081   
    8182    policies = processPool.get()._pluginLoadClientPolicies;
Note: See TracChangeset for help on using the changeset viewer.