Changeset 167202 in webkit


Ignore:
Timestamp:
Apr 13, 2014 1:02:13 PM (10 years ago)
Author:
aestes@apple.com
Message:

REGRESSION (r167164): -[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:] _block_invoke can access a deallocated completionHandler
https://bugs.webkit.org/show_bug.cgi?id=131595

Reviewed by Dan Bernstein.

Make a copy of completionHandler and release it after we're done with it.

  • Shared/mac/CookieStorageShim.mm:

(-[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:]):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167201 r167202  
     12014-04-13  Andy Estes  <aestes@apple.com>
     2
     3        REGRESSION (r167164): -[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:] _block_invoke can access a deallocated completionHandler
     4        https://bugs.webkit.org/show_bug.cgi?id=131595
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Make a copy of completionHandler and release it after we're done with it.
     9
     10        * Shared/mac/CookieStorageShim.mm:
     11        (-[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:]):
     12
    1132014-04-13  Pratik Solanki  <psolanki@apple.com>
    214
  • trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm

    r167164 r167202  
    117117
    118118#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    119 - (void)_getCookieHeadersForTask:(NSURLSessionTask*)task completionHandler:(void (^)(CFDictionaryRef))completionHandler
     119using CompletionHandlerBlock = void(^)(CFDictionaryRef);
     120- (void)_getCookieHeadersForTask:(NSURLSessionTask*)task completionHandler:(CompletionHandlerBlock)completionHandler
    120121{
    121122    if (!completionHandler)
     
    123124
    124125    RetainPtr<NSURLSessionTask> strongTask = task;
    125     RunLoop::main().dispatch([strongTask, completionHandler]{
    126         completionHandler(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, (CFURLRef)[[strongTask currentRequest] URL]));
     126    CompletionHandlerBlock completionHandlerCopy = [completionHandler copy];
     127    RunLoop::main().dispatch([strongTask, completionHandlerCopy]{
     128        completionHandlerCopy(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, (CFURLRef)[[strongTask currentRequest] URL]));
     129        [completionHandlerCopy release];
    127130    });
    128131}
Note: See TracChangeset for help on using the changeset viewer.