Title: [274675] trunk/Source/WebCore
Revision
274675
Author
commit-qu...@webkit.org
Date
2021-03-18 15:09:49 -0700 (Thu, 18 Mar 2021)

Log Message

Protect frame before calling setPrinting
https://bugs.webkit.org/show_bug.cgi?id=222664

Patch by Rob Buis <rb...@igalia.com> on 2021-03-18
Reviewed by Ryosuke Niwa.

Protect frame before calling setPrinting
since it could potentially delete the frame
through event handling.

* page/PrintContext.cpp:
(WebCore::PrintContext::begin):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274674 => 274675)


--- trunk/Source/WebCore/ChangeLog	2021-03-18 21:41:33 UTC (rev 274674)
+++ trunk/Source/WebCore/ChangeLog	2021-03-18 22:09:49 UTC (rev 274675)
@@ -1,3 +1,17 @@
+2021-03-18  Rob Buis  <rb...@igalia.com>
+
+        Protect frame before calling setPrinting
+        https://bugs.webkit.org/show_bug.cgi?id=222664
+
+        Reviewed by Ryosuke Niwa.
+
+        Protect frame before calling setPrinting
+        since it could potentially delete the frame
+        through event handling.
+
+        * page/PrintContext.cpp:
+        (WebCore::PrintContext::begin):
+
 2021-03-18  Antti Koivisto  <an...@apple.com>
 
         Switch out of scheduled resource load mode only after async scripts have run

Modified: trunk/Source/WebCore/page/PrintContext.cpp (274674 => 274675)


--- trunk/Source/WebCore/page/PrintContext.cpp	2021-03-18 21:41:33 UTC (rev 274674)
+++ trunk/Source/WebCore/page/PrintContext.cpp	2021-03-18 22:09:49 UTC (rev 274675)
@@ -191,15 +191,15 @@
     if (!frame())
         return;
 
-    auto& frame = *this->frame();
+    auto frame = makeRef(*this->frame());
     // This function can be called multiple times to adjust printing parameters without going back to screen mode.
     m_isPrinting = true;
 
     FloatSize originalPageSize = FloatSize(width, height);
-    FloatSize minLayoutSize = frame.resizePageRectsKeepingRatio(originalPageSize, FloatSize(width * minimumShrinkFactor(), height * minimumShrinkFactor()));
+    FloatSize minLayoutSize = frame->resizePageRectsKeepingRatio(originalPageSize, FloatSize(width * minimumShrinkFactor(), height * minimumShrinkFactor()));
 
     // This changes layout, so callers need to make sure that they don't paint to screen while in printing mode.
-    frame.setPrinting(true, minLayoutSize, originalPageSize, maximumShrinkFactor() / minimumShrinkFactor(), AdjustViewSize);
+    frame->setPrinting(true, minLayoutSize, originalPageSize, maximumShrinkFactor() / minimumShrinkFactor(), AdjustViewSize);
 }
 
 float PrintContext::computeAutomaticScaleFactor(const FloatSize& availablePaperSize)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to