Commit 8c41028
committed
REGRESSION (298372@main): Occasional CheckedPtr crash when executing insertUnorderedList command
https://bugs.webkit.org/show_bug.cgi?id=299492
rdar://161086162
Reviewed by Abrar Rahman Protyasha and Ryosuke Niwa.
After the changes in 298372@main, we now crash when decrementing `CheckedPtr<RenderStyle>`
underneath `EditingStyle::init`:
```
if (node && node->computedStyle()) {
CheckedPtr renderStyle = node->computedStyle();
removeTextFillAndStrokeColorsIfNeeded(renderStyle.get());
if (renderStyle->fontDescription().keywordSize()) {
if (auto cssValue = computedStyleAtPosition.getFontSizeCSSValuePreferringKeyword())
mutableStyle->setProperty(CSSPropertyFontSize, cssValue->cssText(CSS::defaultSerializationContext()));
}
}
```
This is because `getFontSizeCSSValuePreferringKeyword()` updates layout, which could potentially
destroy and recreate the node's renderer along with its `RenderStyle`. To fix this, we simply limit
the scope of the `CheckedPtr` so that it doesn't outlive the layout update.
Test: editing/execCommand/insert-unordered-list-after-DOMNodeRemoved.html
* LayoutTests/editing/execCommand/insert-unordered-list-after-DOMNodeRemoved-expected.txt: Added.
* LayoutTests/editing/execCommand/insert-unordered-list-after-DOMNodeRemoved.html: Added.
Add a test to exercise the fix; this test passes if it does not crash.
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::EditingStyle::init):
Canonical link: https://commits.webkit.org/300502@main1 parent 139792a commit 8c41028
File tree
3 files changed
+65
-3
lines changed- LayoutTests/editing/execCommand
- Source/WebCore/editing
3 files changed
+65
-3
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 56 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
594 | | - | |
595 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
596 | 601 | | |
597 | 602 | | |
598 | 603 | | |
| |||
0 commit comments