⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276186 in webkit


Ignore:
Timestamp:
Apr 16, 2021, 5:57:21 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Nullptr deref in CompositeEditCommand::isRemovableBlock in DeleteSelectionCommand::removeRedundantBlocks
https://bugs.webkit.org/show_bug.cgi?id=224518

Patch by Ian Gilbert <iang@apple.com> on 2021-04-16
Reviewed by Ryosuke Niwa.

Source/WebCore:

Add null check in case node is removed while iterating over tree.

Test: editing/execCommand/remove-node-during-command-crash.html

  • editing/DeleteSelectionCommand.cpp:

(WebCore::DeleteSelectionCommand::removeRedundantBlocks):

LayoutTests:

Add a regression test.

  • editing/execCommand/remove-node-during-command-crash-expected.txt: Added.
  • editing/execCommand/remove-node-during-command-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r276182 r276186  
     12021-04-16  Ian Gilbert  <iang@apple.com>
     2
     3        Nullptr deref in CompositeEditCommand::isRemovableBlock in DeleteSelectionCommand::removeRedundantBlocks
     4        https://bugs.webkit.org/show_bug.cgi?id=224518
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add a regression test.
     9
     10        * editing/execCommand/remove-node-during-command-crash-expected.txt: Added.
     11        * editing/execCommand/remove-node-during-command-crash.html: Added.
     12
    1132021-04-16  Cameron McCormack  <heycam@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r276182 r276186  
     12021-04-16  Ian Gilbert  <iang@apple.com>
     2
     3        Nullptr deref in CompositeEditCommand::isRemovableBlock in DeleteSelectionCommand::removeRedundantBlocks
     4        https://bugs.webkit.org/show_bug.cgi?id=224518
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add null check in case node is removed while iterating over tree.
     9
     10        Test: editing/execCommand/remove-node-during-command-crash.html
     11
     12        * editing/DeleteSelectionCommand.cpp:
     13        (WebCore::DeleteSelectionCommand::removeRedundantBlocks):
     14
    1152021-04-16  Cameron McCormack  <heycam@apple.com>
    216
  • trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp

    r273866 r276186  
    866866void DeleteSelectionCommand::removeRedundantBlocks()
    867867{
    868     Node* node = m_endingPosition.containerNode();
    869     Node* rootNode = node->rootEditableElement();
     868    auto node = makeRefPtr(m_endingPosition.containerNode());
     869    auto rootNode = makeRefPtr(node->rootEditableElement());
    870870   
    871     while (node != rootNode) {
    872         if (isRemovableBlock(node)) {
     871    while (node && node != rootNode) {
     872        if (isRemovableBlock(node.get())) {
    873873            if (node == m_endingPosition.anchorNode())
    874874                updatePositionForNodeRemovalPreservingChildren(m_endingPosition, *node);
Note: See TracChangeset for help on using the changeset viewer.