Title: [283294] trunk/Source/WebKit
Revision
283294
Author
[email protected]
Date
2021-09-29 19:01:37 -0700 (Wed, 29 Sep 2021)

Log 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 <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (283293 => 283294)


--- trunk/Source/WebKit/ChangeLog	2021-09-30 01:39:22 UTC (rev 283293)
+++ trunk/Source/WebKit/ChangeLog	2021-09-30 02:01:37 UTC (rev 283294)
@@ -1,3 +1,19 @@
+2021-09-29  Alex Christensen  <[email protected]>
+
+        Add weakThis check in addition to null check added in r282881
+        https://bugs.webkit.org/show_bug.cgi?id=231000
+        <rdar://83605614>
+
+        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):
+
 2021-09-29  Per Arne Vollan <[email protected]>
 
         [macOS] Allow audio service in the WebContent process on older versions

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (283293 => 283294)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2021-09-30 01:39:22 UTC (rev 283293)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2021-09-30 02:01:37 UTC (rev 283294)
@@ -343,12 +343,13 @@
     parameters.isNavigatingToAppBoundDomain = m_parameters.isNavigatingToAppBoundDomain;
     m_networkLoad = makeUnique<NetworkLoad>(*this, &networkSession->blobRegistry(), WTFMove(parameters), *networkSession);
     
+    auto weakThis = makeWeakPtr(*this);
     if (isSynchronous())
-        m_networkLoad->start();
+        m_networkLoad->start(); // May delete this object
     else
         m_networkLoad->startWithScheduling();
 
-    if (m_networkLoad)
+    if (weakThis && m_networkLoad)
         LOADER_RELEASE_LOG("startNetworkLoad: Going to the network (description=%" PUBLIC_LOG_STRING ")", m_networkLoad->description().utf8().data());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to