Changeset 86200 in webkit


Ignore:
Timestamp:
May 10, 2011 5:46:02 PM (13 years ago)
Author:
psolanki@apple.com
Message:

Protect self in [WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]
https://bugs.webkit.org/show_bug.cgi?id=60594
<rdar://problem/9203259>

Reviewed by Alexey Proskuryakov.

No tests since we don't have any bots testing CFNETWORK_DATA_ARRAY_CALLBACK.

  • platform/network/mac/ResourceHandleMac.mm:

(-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]): The didReceiveData()
callback on client can result in the load being cancelled. This results in the delegate
(self) being freed. Protect self during the loop so we can check for m_handle and safely
return without crashing.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86199 r86200  
     12011-05-10  Pratik Solanki  <psolanki@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        Protect self in [WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]
     6        https://bugs.webkit.org/show_bug.cgi?id=60594
     7        <rdar://problem/9203259>
     8
     9        No tests since we don't have any bots testing CFNETWORK_DATA_ARRAY_CALLBACK.
     10
     11        * platform/network/mac/ResourceHandleMac.mm:
     12        (-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]): The didReceiveData()
     13        callback on client can result in the load being cancelled. This results in the delegate
     14        (self) being freed.  Protect self during the loop so we can check for m_handle and safely
     15        return without crashing.
     16
    1172011-05-10  Chris Guillory  <chris.guillory@google.com>
    218
  • trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm

    r85256 r86200  
    827827        m_handle->client()->didReceiveDataArray(m_handle, reinterpret_cast<CFArrayRef>(dataArray));
    828828    else {
    829         for (NSData *data in dataArray)
     829        // The call to didReceiveData below could cancel a load, which would result in the delegate
     830        // (self) being released.
     831        RetainPtr<WebCoreResourceHandleAsDelegate> protect(self);
     832        for (NSData *data in dataArray) {
     833            if (!m_handle)
     834                break;
    830835            m_handle->client()->didReceiveData(m_handle, static_cast<const char*>([data bytes]), [data length], static_cast<int>([data length]));
     836        }
    831837    }
    832838    return;
Note: See TracChangeset for help on using the changeset viewer.