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

Changeset 269137 in webkit


Ignore:
Timestamp:
Oct 28, 2020, 10:26:10 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Null dereference in CompositeEditCommand::cloneParagraphUnderNewElement() due to not checking for top of DOM tree
https://bugs.webkit.org/show_bug.cgi?id=218132

Patch by Julian Gonzalez <julian_a_gonzalez@apple.com> on 2020-10-28
Reviewed by Ryosuke Niwa.

Source/WebCore:

When iterating through parent nodes, cloneParagraphUnderNewElement()
has to be careful to check for the top of the DOM tree (where
parentNode() returns nullptr) and stop iterating.

  • editing/CompositeEditCommand.cpp:

(WebCore::CompositeEditCommand::cloneParagraphUnderNewElement):

LayoutTests:

Add a test to verify that we don't iterate outside the DOM tree while cloning a paragraph.
Thanks to Ryosuke Niwa for helping minimize the test and make it more stable.

  • editing/deleting/move-paragraph-crash-expected.txt: Added.
  • editing/deleting/move-paragraph-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r269136 r269137  
     12020-10-28  Julian Gonzalez  <julian_a_gonzalez@apple.com>
     2
     3        Null dereference in CompositeEditCommand::cloneParagraphUnderNewElement() due to not checking for top of DOM tree
     4        https://bugs.webkit.org/show_bug.cgi?id=218132
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add a test to verify that we don't iterate outside the DOM tree while cloning a paragraph.
     9        Thanks to Ryosuke Niwa for helping minimize the test and make it more stable.
     10
     11        * editing/deleting/move-paragraph-crash-expected.txt: Added.
     12        * editing/deleting/move-paragraph-crash.html: Added.
     13
    1142020-10-28  Ryosuke Niwa  <rniwa@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r269136 r269137  
     12020-10-28  Julian Gonzalez  <julian_a_gonzalez@apple.com>
     2
     3        Null dereference in CompositeEditCommand::cloneParagraphUnderNewElement() due to not checking for top of DOM tree
     4        https://bugs.webkit.org/show_bug.cgi?id=218132
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When iterating through parent nodes, cloneParagraphUnderNewElement()
     9        has to be careful to check for the top of the DOM tree (where
     10        parentNode() returns nullptr) and stop iterating.
     11
     12        * editing/CompositeEditCommand.cpp:
     13        (WebCore::CompositeEditCommand::cloneParagraphUnderNewElement):
     14
    1152020-10-28  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r267363 r269137  
    12691269        // find the first common ancestor to increase the scope
    12701270        // of our nextSibling traversal.
    1271         while (!end.deprecatedNode()->isDescendantOf(outerNode.get())) {
     1271        while (!end.deprecatedNode()->isDescendantOf(outerNode.get()) && outerNode->parentNode()) {
    12721272            outerNode = outerNode->parentNode();
    12731273        }
     
    12781278            // tree by NodeTraversal::nextSkippingChildren, so that the relative depth between
    12791279            // node and the original start node is maintained in the clone.
    1280             while (startNode->parentNode() != node->parentNode()) {
     1280            while (startNode->parentNode() && startNode->parentNode() != node->parentNode()) {
    12811281                startNode = startNode->parentNode();
    12821282                lastNode = lastNode->parentNode();
     1283                ASSERT(lastNode);
    12831284            }
    12841285
Note: See TracChangeset for help on using the changeset viewer.