Changeset 273302 in webkit


Ignore:
Timestamp:
Feb 23, 2021 4:28:20 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Nullptr crash in ModifySelectionListLevelCommand::appendSiblingNodeRange
https://bugs.webkit.org/show_bug.cgi?id=221650

Patch by Frederic Wang <fwang@igalia.com> on 2021-02-23
Reviewed by Ryosuke Niwa.

Source/WebCore:

getStartEndListChildren relies on the render tree to move the "end" node to the next sibling,
but this does not necessarily correspond to a sibling of the "start" node in the DOM tree.
This breaks the assumption of ModifySelectionListLevelCommand::appendSiblingNodeRange that
the "start" and "end" nodes are siblings (in that order), causing a null-pointer dereference.
This patch fixes the issue by ensuring that getStartEndListChildren does not try to change
the "end" node if it is not a sibling of the "start" one.

Test: fast/editing/modify-selection-list-level-crash.html

  • editing/ModifySelectionListLevel.cpp:

(WebCore::getStartEndListChildren): Don't change the end node if r->node() is a sibling of
startChildList.

LayoutTests:

  • fast/editing/modify-selection-list-level-crash-expected.txt: Added.
  • fast/editing/modify-selection-list-level-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r273301 r273302  
     12021-02-23  Frederic Wang  <fwang@igalia.com>
     2
     3        Nullptr crash in ModifySelectionListLevelCommand::appendSiblingNodeRange
     4        https://bugs.webkit.org/show_bug.cgi?id=221650
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * fast/editing/modify-selection-list-level-crash-expected.txt: Added.
     9        * fast/editing/modify-selection-list-level-crash.html: Added.
     10
    1112021-02-23  Kimmo Kinnunen  <kkinnunen@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r273300 r273302  
     12021-02-23  Frederic Wang  <fwang@igalia.com>
     2
     3        Nullptr crash in ModifySelectionListLevelCommand::appendSiblingNodeRange
     4        https://bugs.webkit.org/show_bug.cgi?id=221650
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        getStartEndListChildren relies on the render tree to move the "end" node to the next sibling,
     9        but this does not necessarily correspond to a sibling of the "start" node in the DOM tree.
     10        This breaks the assumption of ModifySelectionListLevelCommand::appendSiblingNodeRange that
     11        the "start" and "end" nodes are siblings (in that order), causing a null-pointer dereference.
     12        This patch fixes the issue by ensuring that getStartEndListChildren does not try to change
     13        the "end" node if it is not a sibling of the "start" one.
     14
     15        Test: fast/editing/modify-selection-list-level-crash.html
     16
     17        * editing/ModifySelectionListLevel.cpp:
     18        (WebCore::getStartEndListChildren): Don't change the end node if r->node() is a sibling of
     19        startChildList.
     20
    1212021-02-23  Ryosuke Niwa  <rniwa@webkit.org>
    222
  • trunk/Source/WebCore/editing/ModifySelectionListLevel.cpp

    r272556 r273302  
    8181    if (endListChild->renderer()->isListItem()) {
    8282        RenderObject* r = endListChild->renderer()->nextSibling();
    83         if (r && isListHTMLElement(r->node()))
     83        if (r && isListHTMLElement(r->node()) && r->node()->parentNode() == startListChild->parentNode())
    8484            endListChild = r->node();
    8585    }
Note: See TracChangeset for help on using the changeset viewer.