⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283294 in webkit


Ignore:
Timestamp:
Sep 29, 2021, 7:01:37 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Add weakThis check in addition to null check added in r282881
https://bugs.webkit.org/show_bug.cgi?id=231000
<rdar://83605614>

Patch by Alex Christensen <achristensen@webkit.org> on 2021-09-29
Reviewed by Brady Eidson.

r282881 made NetworkLoad::start call didCompleteWithError, which can cause the
NetworkResourceLoader to be deleted. It added a null check on m_networkLoad which
sometimes reads freed memory. This certainly isn't great, but luckily we have a way
to check if this object has been deleted. Let's do that.

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::startNetworkLoad):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r283289 r283294  
     12021-09-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add weakThis check in addition to null check added in r282881
     4        https://bugs.webkit.org/show_bug.cgi?id=231000
     5        <rdar://83605614>
     6
     7        Reviewed by Brady Eidson.
     8
     9        r282881 made NetworkLoad::start call didCompleteWithError, which can cause the
     10        NetworkResourceLoader to be deleted.  It added a null check on m_networkLoad which
     11        sometimes reads freed memory.  This certainly isn't great, but luckily we have a way
     12        to check if this object has been deleted.  Let's do that.
     13
     14        * NetworkProcess/NetworkResourceLoader.cpp:
     15        (WebKit::NetworkResourceLoader::startNetworkLoad):
     16
    1172021-09-29  Per Arne Vollan <pvollan@apple.com>
    218
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r283283 r283294  
    344344    m_networkLoad = makeUnique<NetworkLoad>(*this, &networkSession->blobRegistry(), WTFMove(parameters), *networkSession);
    345345   
     346    auto weakThis = makeWeakPtr(*this);
    346347    if (isSynchronous())
    347         m_networkLoad->start();
     348        m_networkLoad->start(); // May delete this object
    348349    else
    349350        m_networkLoad->startWithScheduling();
    350351
    351     if (m_networkLoad)
     352    if (weakThis && m_networkLoad)
    352353        LOADER_RELEASE_LOG("startNetworkLoad: Going to the network (description=%" PUBLIC_LOG_STRING ")", m_networkLoad->description().utf8().data());
    353354}
Note: See TracChangeset for help on using the changeset viewer.