Title: [253805] trunk
Revision
253805
Author
[email protected]
Date
2019-12-19 18:00:56 -0800 (Thu, 19 Dec 2019)

Log Message

Nullptr crash in WebCore::findPlaceForCounter with display: contents parent
https://bugs.webkit.org/show_bug.cgi?id=205290

Patch by Jack Lee <[email protected]> on 2019-12-19
Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: fast/css/counters/findPlaceForCounter-crash.html

* rendering/RenderCounter.cpp:
(WebCore::parentOrPseudoHostElement):

LayoutTests:

* fast/css/counters/findPlaceForCounter-crash-expected.txt: Added.
* fast/css/counters/findPlaceForCounter-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253804 => 253805)


--- trunk/LayoutTests/ChangeLog	2019-12-20 01:06:22 UTC (rev 253804)
+++ trunk/LayoutTests/ChangeLog	2019-12-20 02:00:56 UTC (rev 253805)
@@ -1,3 +1,13 @@
+2019-12-19  Jack Lee  <[email protected]>
+
+        Nullptr crash in WebCore::findPlaceForCounter with display: contents parent
+        https://bugs.webkit.org/show_bug.cgi?id=205290
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/css/counters/findPlaceForCounter-crash-expected.txt: Added.
+        * fast/css/counters/findPlaceForCounter-crash.html: Added.
+
 2019-12-19  Charlie Turner  <[email protected]>
 
         [GTK] http/tests/media/clearkey/collect-webkit-media-session.html is timing out since added in r235429 "WebKitMediaSession should be GC collectable when its document is being stopped"

Added: trunk/LayoutTests/fast/css/counters/findPlaceForCounter-crash-expected.txt (0 => 253805)


--- trunk/LayoutTests/fast/css/counters/findPlaceForCounter-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/counters/findPlaceForCounter-crash-expected.txt	2019-12-20 02:00:56 UTC (rev 253805)
@@ -0,0 +1,4 @@
+This tests an element with CSS counter having a parent with display: contents.
+
+The test passes if WebKit doesn't crash or hit an assertion.
+

Added: trunk/LayoutTests/fast/css/counters/findPlaceForCounter-crash.html (0 => 253805)


--- trunk/LayoutTests/fast/css/counters/findPlaceForCounter-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/counters/findPlaceForCounter-crash.html	2019-12-20 02:00:56 UTC (rev 253805)
@@ -0,0 +1,16 @@
+<style>
+data,li,body,html {counter-reset: c;}
+</style>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+_onload_ = function eventhandler1() {
+    li.style.setProperty("counter-increment", "c");
+}
+</script>
+<body>
+<p>This tests an element with CSS counter having a parent with display: contents.</p>
+<p>The test passes if WebKit doesn't crash or hit an assertion.</p>
+</body>
+<data style="display: contents"><li id="li">

Modified: trunk/Source/WebCore/ChangeLog (253804 => 253805)


--- trunk/Source/WebCore/ChangeLog	2019-12-20 01:06:22 UTC (rev 253804)
+++ trunk/Source/WebCore/ChangeLog	2019-12-20 02:00:56 UTC (rev 253805)
@@ -1,3 +1,15 @@
+2019-12-19  Jack Lee  <[email protected]>
+
+        Nullptr crash in WebCore::findPlaceForCounter with display: contents parent
+        https://bugs.webkit.org/show_bug.cgi?id=205290
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: fast/css/counters/findPlaceForCounter-crash.html
+
+        * rendering/RenderCounter.cpp:
+        (WebCore::parentOrPseudoHostElement):
+
 2019-12-19  Chris Dumez  <[email protected]>
 
         REGRESSION: (r251677) imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-double-submit-3.html is a flaky failure

Modified: trunk/Source/WebCore/rendering/RenderCounter.cpp (253804 => 253805)


--- trunk/Source/WebCore/rendering/RenderCounter.cpp	2019-12-20 01:06:22 UTC (rev 253804)
+++ trunk/Source/WebCore/rendering/RenderCounter.cpp	2019-12-20 02:00:56 UTC (rev 253805)
@@ -72,7 +72,15 @@
 {
     if (renderer.isPseudoElement())
         return renderer.generatingElement();
-    return renderer.element() ? renderer.element()->parentElement() : nullptr;
+
+    ASSERT(renderer.element());
+    auto parent = makeRefPtr(renderer.element()->parentElement());
+    while (parent) {
+        if (!parent->hasDisplayContents())
+            break;
+        parent = parent->parentElement();
+    }
+    return parent.get();
 }
 
 // This function processes the renderer tree in the order of the DOM tree
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to