Title: [259580] trunk/Source/WebKit
Revision
259580
Author
[email protected]
Date
2020-04-06 11:08:21 -0700 (Mon, 06 Apr 2020)

Log Message

CrashTracer: MobileSafari at WebKit: WebKit::SystemPreviewController::updateProgress
https://bugs.webkit.org/show_bug.cgi?id=210040
rdar://51410841

Reviewed by Darin Adler.

It appears that the SystemPreviewController on WebPageProxy can
become null causing a call to an in-progress download to crash
as it tries to talk to the QuickLook delegate. Guard against this
by checking the SystemPreviewController each time.

* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::systemPreviewController):
(WebKit::DownloadClient::didReceiveResponse):
(WebKit::DownloadClient::didReceiveData):
(WebKit::DownloadClient::processDidCrash):
(WebKit::DownloadClient::didFinish):
(WebKit::DownloadClient::didFail):
(WebKit::DownloadClient::didCancel):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (259579 => 259580)


--- trunk/Source/WebKit/ChangeLog	2020-04-06 18:07:25 UTC (rev 259579)
+++ trunk/Source/WebKit/ChangeLog	2020-04-06 18:08:21 UTC (rev 259580)
@@ -1,3 +1,25 @@
+2020-04-06  Dean Jackson  <[email protected]>
+
+        CrashTracer: MobileSafari at WebKit: WebKit::SystemPreviewController::updateProgress
+        https://bugs.webkit.org/show_bug.cgi?id=210040
+        rdar://51410841
+
+        Reviewed by Darin Adler.
+
+        It appears that the SystemPreviewController on WebPageProxy can
+        become null causing a call to an in-progress download to crash
+        as it tries to talk to the QuickLook delegate. Guard against this
+        by checking the SystemPreviewController each time.
+
+        * UIProcess/Cocoa/DownloadClient.mm:
+        (WebKit::systemPreviewController):
+        (WebKit::DownloadClient::didReceiveResponse):
+        (WebKit::DownloadClient::didReceiveData):
+        (WebKit::DownloadClient::processDidCrash):
+        (WebKit::DownloadClient::didFinish):
+        (WebKit::DownloadClient::didFail):
+        (WebKit::DownloadClient::didCancel):
+
 2020-04-06  Chris Dumez  <[email protected]>
 
         ProcessAssertion should use ASCIILiteral for its reason

Modified: trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm (259579 => 259580)


--- trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2020-04-06 18:07:25 UTC (rev 259579)
+++ trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2020-04-06 18:08:21 UTC (rev 259580)
@@ -65,6 +65,16 @@
     m_delegateMethods.downloadProcessDidCrash = [delegate respondsToSelector:@selector(_downloadProcessDidCrash:)];
 }
 
+#if USE(SYSTEM_PREVIEW)
+static SystemPreviewController* systemPreviewController(DownloadProxy& downloadProxy)
+{
+    auto* page = downloadProxy.originatingPage();
+    if (!page)
+        return nullptr;
+    return page->systemPreviewController();
+}
+#endif
+
 void DownloadClient::didStart(DownloadProxy& downloadProxy)
 {
 #if USE(SYSTEM_PREVIEW)
@@ -88,8 +98,8 @@
     if (downloadProxy.isSystemPreviewDownload() && response.isSuccessful()) {
         downloadProxy.setExpectedContentLength(response.expectedContentLength());
         downloadProxy.setBytesLoaded(0);
-        if (auto* webPage = downloadProxy.originatingPage())
-            webPage->systemPreviewController()->updateProgress(0);
+        if (auto* controller = systemPreviewController(downloadProxy))
+            controller->updateProgress(0);
         return;
     }
 #endif
@@ -103,8 +113,8 @@
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
         downloadProxy.setBytesLoaded(downloadProxy.bytesLoaded() + length);
-        if (auto* webPage = downloadProxy.originatingPage())
-            webPage->systemPreviewController()->updateProgress(static_cast<float>(downloadProxy.bytesLoaded()) / downloadProxy.expectedContentLength());
+        if (auto* controller = systemPreviewController(downloadProxy))
+            controller->updateProgress(static_cast<float>(downloadProxy.bytesLoaded()) / downloadProxy.expectedContentLength());
         return;
     }
 #endif
@@ -164,8 +174,8 @@
 {
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
-        if (auto* webPage = downloadProxy.originatingPage())
-            webPage->systemPreviewController()->cancel();
+        if (auto* controller = systemPreviewController(downloadProxy))
+            controller->cancel();
         releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
@@ -209,11 +219,11 @@
 {
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
-        if (auto* webPage = downloadProxy.originatingPage()) {
+        if (auto* controller = systemPreviewController(downloadProxy)) {
             WTF::URL destinationURL = WTF::URL::fileURLWithFileSystemPath(downloadProxy.destinationFilename());
             if (!destinationURL.fragmentIdentifier().length())
                 destinationURL.setFragmentIdentifier(downloadProxy.request().url().fragmentIdentifier());
-            webPage->systemPreviewController()->finish(destinationURL);
+            controller->finish(destinationURL);
         }
         releaseActivityTokenIfNecessary(downloadProxy);
         return;
@@ -228,8 +238,8 @@
 {
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
-        if (auto* webPage = downloadProxy.originatingPage())
-            webPage->systemPreviewController()->fail(error);
+        if (auto* controller = systemPreviewController(downloadProxy))
+            controller->fail(error);
         releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
@@ -243,8 +253,8 @@
 {
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
-        if (auto* webPage = downloadProxy.originatingPage())
-            webPage->systemPreviewController()->cancel();
+        if (auto* controller = systemPreviewController(downloadProxy))
+            controller->cancel();
         releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to