Title: [250511] branches/safari-608-branch/Source/WebKit
Revision
250511
Author
[email protected]
Date
2019-09-30 01:30:55 -0700 (Mon, 30 Sep 2019)

Log Message

Cherry-pick r250394. rdar://problem/55826250

    Crash under WebPage::beginPrinting when m_printContext becomes null due to synchronous layout
    https://bugs.webkit.org/show_bug.cgi?id=202171
    <rdar://problem/49731211>

    Reviewed by Tim Horton.

    Speculatively fix a null pointer dereference crash in WebPage::beginPrinting.

    WebPage::beginPrinting creates a PrintContext, stores it in m_printContext, then calls
    PrintContext::begin which forces a synchronous, paginated layout. If a post-layout task
    executes script, that might result in the WebPage being closed and m_printContext being set
    to nullptr.

    Guard against this in WebPage::beginPrinting by adding a null check before calling
    PrintContext::computePageRects.

    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::beginPrinting):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250394 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (250510 => 250511)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-09-30 08:30:53 UTC (rev 250510)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-09-30 08:30:55 UTC (rev 250511)
@@ -1,3 +1,50 @@
+2019-09-30  Babak Shafiei  <[email protected]>
+
+        Cherry-pick r250394. rdar://problem/55826250
+
+    Crash under WebPage::beginPrinting when m_printContext becomes null due to synchronous layout
+    https://bugs.webkit.org/show_bug.cgi?id=202171
+    <rdar://problem/49731211>
+    
+    Reviewed by Tim Horton.
+    
+    Speculatively fix a null pointer dereference crash in WebPage::beginPrinting.
+    
+    WebPage::beginPrinting creates a PrintContext, stores it in m_printContext, then calls
+    PrintContext::begin which forces a synchronous, paginated layout. If a post-layout task
+    executes script, that might result in the WebPage being closed and m_printContext being set
+    to nullptr.
+    
+    Guard against this in WebPage::beginPrinting by adding a null check before calling
+    PrintContext::computePageRects.
+    
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::beginPrinting):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250394 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-09-26  Andy Estes  <[email protected]>
+
+            Crash under WebPage::beginPrinting when m_printContext becomes null due to synchronous layout
+            https://bugs.webkit.org/show_bug.cgi?id=202171
+            <rdar://problem/49731211>
+
+            Reviewed by Tim Horton.
+
+            Speculatively fix a null pointer dereference crash in WebPage::beginPrinting.
+
+            WebPage::beginPrinting creates a PrintContext, stores it in m_printContext, then calls
+            PrintContext::begin which forces a synchronous, paginated layout. If a post-layout task
+            executes script, that might result in the WebPage being closed and m_printContext being set
+            to nullptr.
+
+            Guard against this in WebPage::beginPrinting by adding a null check before calling
+            PrintContext::computePageRects.
+
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::beginPrinting):
+
 2019-09-29  Alan Coon  <[email protected]>
 
         Cherry-pick r250345. rdar://problem/55825352

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (250510 => 250511)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-30 08:30:53 UTC (rev 250510)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-30 08:30:55 UTC (rev 250511)
@@ -4705,6 +4705,14 @@
     auto computedPageSize = m_printContext->computedPageSize(FloatSize(printInfo.availablePaperWidth, printInfo.availablePaperHeight), printInfo.margin);
     m_printContext->begin(computedPageSize.width(), computedPageSize.height());
 
+    // PrintContext::begin() performed a synchronous layout which might have executed a
+    // script that closed the WebPage, clearing m_printContext.
+    // See <rdar://problem/49731211> for cases of this happening.
+    if (!m_printContext) {
+        unfreezeLayerTree(LayerTreeFreezeReason::Printing);
+        return;
+    }
+
     float fullPageHeight;
     m_printContext->computePageRects(FloatRect(0, 0, computedPageSize.width(), computedPageSize.height()), 0, 0, printInfo.pageSetupScaleFactor, fullPageHeight, true);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to