Commit 277383f
committed
Fix crash in style invalidation when element has no parent during removal
https://bugs.webkit.org/show_bug.cgi?id=301879
rdar://163025404
Reviewed by Antti Koivisto.
This is a fuzzer found bug that results in a crash.
When hidePopoverInternal() is called during element removal (due to outerText being set),
style invalidation runs even when parentNode is null. This is
incorrect. We shouldn't be entering style invalidation in this case at all.
While the rest of the cleanup in hidePopoverInternal() is necessary, style
invalidation is not here.
As a result, this fix adds a null check to only perform style invalidation
when elements are NOT being removed (aka its parent still exists). Since we
add this check, the existing null check further down in invalidateStyleWithMatchElement()
is redundant and no longer necessary.
There were 2 previous attempted fixes for this: 286644@main and 293967@main.
286644@main had an incorrect Style::InvalidationScope::Descendants. 293967@main didn't
add null checks to the other relevant cases in invalidateStyleWithMatchElement().
This PR correctly implements the full fix.
Test: fast/dom/Element/nth-child-of-popover-open-crash.html
* LayoutTests/fast/dom/Element/nth-child-of-popover-open-crash-expected.txt: Added.
* LayoutTests/fast/dom/Element/nth-child-of-popover-open-crash.html: Added.
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::hidePopoverInternal):
* Source/WebCore/style/StyleInvalidator.cpp:
(WebCore::Style::Invalidator::invalidateStyleWithMatchElement):
Canonical link: https://commits.webkit.org/303507@main1 parent 5e283cb commit 277383f
File tree
4 files changed
+24
-5
lines changed- LayoutTests/fast/dom/Element
- Source/WebCore
- html
- style
4 files changed
+24
-5
lines changedLines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1243 | 1243 | | |
1244 | 1244 | | |
1245 | 1245 | | |
1246 | | - | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
1247 | 1249 | | |
1248 | 1250 | | |
1249 | 1251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
| 306 | + | |
| 307 | + | |
310 | 308 | | |
311 | 309 | | |
312 | 310 | | |
| |||
0 commit comments