Title: [292175] trunk/Source/WebKit
Revision
292175
Author
achristen...@apple.com
Date
2022-03-31 14:19:40 -0700 (Thu, 31 Mar 2022)

Log Message

null check page in API::DataTask constructor
https://bugs.webkit.org/show_bug.cgi?id=238632
<rdar://90936679>

Reviewed by Tim Horton.

If the page is deallocated between the request to make a data task and the completion providing
the data task to the API client, we don't want to crash.

* UIProcess/API/APIDataTask.cpp:
(API::DataTask::cancel):
(API::DataTask::DataTask):
(API::m_sessionID):
* UIProcess/API/APIDataTask.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (292174 => 292175)


--- trunk/Source/WebKit/ChangeLog	2022-03-31 21:03:43 UTC (rev 292174)
+++ trunk/Source/WebKit/ChangeLog	2022-03-31 21:19:40 UTC (rev 292175)
@@ -1,5 +1,22 @@
 2022-03-31  Alex Christensen  <achristen...@webkit.org>
 
+        null check page in API::DataTask constructor
+        https://bugs.webkit.org/show_bug.cgi?id=238632
+        <rdar://90936679>
+
+        Reviewed by Tim Horton.
+
+        If the page is deallocated between the request to make a data task and the completion providing
+        the data task to the API client, we don't want to crash.
+
+        * UIProcess/API/APIDataTask.cpp:
+        (API::DataTask::cancel):
+        (API::DataTask::DataTask):
+        (API::m_sessionID):
+        * UIProcess/API/APIDataTask.h:
+
+2022-03-31  Alex Christensen  <achristen...@webkit.org>
+
         Expand adattributiond sandbox slightly to avoid sandbox crashes
         https://bugs.webkit.org/show_bug.cgi?id=238609
         <rdar://91073280>

Modified: trunk/Source/WebKit/UIProcess/API/APIDataTask.cpp (292174 => 292175)


--- trunk/Source/WebKit/UIProcess/API/APIDataTask.cpp	2022-03-31 21:03:43 UTC (rev 292174)
+++ trunk/Source/WebKit/UIProcess/API/APIDataTask.cpp	2022-03-31 21:19:40 UTC (rev 292175)
@@ -42,8 +42,8 @@
 
 void DataTask::cancel()
 {
-    if (m_networkProcess)
-        m_networkProcess->cancelDataTask(m_identifier, m_sessionID);
+    if (m_networkProcess && m_sessionID)
+        m_networkProcess->cancelDataTask(m_identifier, *m_sessionID);
 }
 
 DataTask::DataTask(WebKit::DataTaskIdentifier identifier, WeakPtr<WebKit::WebPageProxy>&& page, WTF::URL&& originalURL)
@@ -50,8 +50,8 @@
     : m_identifier(identifier)
     , m_page(WTFMove(page))
     , m_originalURL(WTFMove(originalURL))
-    , m_networkProcess(m_page->websiteDataStore().networkProcess())
-    , m_sessionID(m_page->sessionID())
+    , m_networkProcess(m_page ? WeakPtr { m_page->websiteDataStore().networkProcess() } : nullptr)
+    , m_sessionID(m_page ? std::optional<PAL::SessionID> { m_page->sessionID() } : std::nullopt)
     , m_client(DataTaskClient::create()) { }
 
 } // namespace API

Modified: trunk/Source/WebKit/UIProcess/API/APIDataTask.h (292174 => 292175)


--- trunk/Source/WebKit/UIProcess/API/APIDataTask.h	2022-03-31 21:03:43 UTC (rev 292174)
+++ trunk/Source/WebKit/UIProcess/API/APIDataTask.h	2022-03-31 21:19:40 UTC (rev 292175)
@@ -63,7 +63,7 @@
     WeakPtr<WebKit::WebPageProxy> m_page;
     WTF::URL m_originalURL;
     WeakPtr<WebKit::NetworkProcessProxy> m_networkProcess;
-    PAL::SessionID m_sessionID;
+    std::optional<PAL::SessionID> m_sessionID;
     Ref<DataTaskClient> m_client;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to