Changeset 167573 in webkit


Ignore:
Timestamp:
Apr 20, 2014 1:54:17 PM (10 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] Crash when setting a bundle parameter to nil
https://bugs.webkit.org/show_bug.cgi?id=131917

Reviewed by Sam Weinig.

  • UIProcess/API/Cocoa/WKProcessPool.mm:

(-[WKProcessPool _setObject:forBundleParameter:]): If the object is nil, use
-[NSMutableDictionary removeObjectForKey:] rather than -setObject:forKey:.

  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessBundleParameters.mm:

(-[WKWebProcessBundleParameters setParameter:forKey:]): Ditto.

  • WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:

(WebKit::InjectedBundle::setBundleParameter): Unrelatedly, create m_bundleParameters if
needed, as it may have not been created on intialization if no bundle parameters were set
at the time.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167572 r167573  
     12014-04-20  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Crash when setting a bundle parameter to nil
     4        https://bugs.webkit.org/show_bug.cgi?id=131917
     5
     6        Reviewed by Sam Weinig.
     7
     8        * UIProcess/API/Cocoa/WKProcessPool.mm:
     9        (-[WKProcessPool _setObject:forBundleParameter:]): If the object is nil, use
     10        -[NSMutableDictionary removeObjectForKey:] rather than -setObject:forKey:.
     11
     12        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessBundleParameters.mm:
     13        (-[WKWebProcessBundleParameters setParameter:forKey:]): Ditto.
     14
     15        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
     16        (WebKit::InjectedBundle::setBundleParameter): Unrelatedly, create m_bundleParameters if
     17        needed, as it may have not been created on intialization if no bundle parameters were set
     18        at the time.
     19
    1202014-04-20  Dan Bernstein  <mitz@apple.com>
    221
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm

    r166959 r167573  
    183183    }
    184184
    185     [_context->ensureBundleParameters() setObject:copy.get() forKey:parameter];
     185    if (copy)
     186        [_context->ensureBundleParameters() setObject:copy.get() forKey:parameter];
     187    else
     188        [_context->ensureBundleParameters() removeObjectForKey:parameter];
     189
    186190    _context->sendToAllProcesses(Messages::WebProcess::SetInjectedBundleParameter(parameter, IPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length])));
    187191}
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessBundleParameters.mm

    r165789 r167573  
    5353{
    5454    [self willChangeValueForKey:key];
    55     [_parameters setValue:parameter forKey:key];
     55    if (parameter)
     56        [_parameters setValue:parameter forKey:key];
     57    else
     58        [_parameters removeObjectForKey:key];
    5659    [self didChangeValueForKey:key];
    5760}
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm

    r166961 r167573  
    153153    }
    154154
     155    if (!m_bundleParameters && parameter)
     156        m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:[NSDictionary dictionary]]);
     157
    155158    [m_bundleParameters setParameter:parameter forKey:key];
    156159#endif
Note: See TracChangeset for help on using the changeset viewer.