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

Changeset 286553 in webkit


Ignore:
Timestamp:
Dec 6, 2021, 11:13:26 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Null check in shouldUseBreakElement
https://bugs.webkit.org/show_bug.cgi?id=229275

Patch by Rob Buis <rbuis@igalia.com> on 2021-12-06
Reviewed by Ryosuke Niwa.

Source/WebCore:

Need to null check node in shouldUseBreakElement.
Also bail out early in InsertLineBreakCommand::doApply
in case position is not editable.

Test: editing/execCommand/insert-line-break-crash.html

  • editing/InsertLineBreakCommand.cpp:

(WebCore::InsertLineBreakCommand::shouldUseBreakElement):
(WebCore::InsertLineBreakCommand::doApply):

LayoutTests:

  • editing/execCommand/insert-line-break-crash-expected.txt: Added.
  • editing/execCommand/insert-line-break-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286550 r286553  
     12021-12-06  Rob Buis  <rbuis@igalia.com>
     2
     3        Null check in shouldUseBreakElement
     4        https://bugs.webkit.org/show_bug.cgi?id=229275
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/execCommand/insert-line-break-crash-expected.txt: Added.
     9        * editing/execCommand/insert-line-break-crash.html: Added.
     10
    1112021-12-06  Tadeu Zagallo  <tzagallo@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r286550 r286553  
     12021-12-06  Rob Buis  <rbuis@igalia.com>
     2
     3        Null check in shouldUseBreakElement
     4        https://bugs.webkit.org/show_bug.cgi?id=229275
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Need to null check node in shouldUseBreakElement.
     9        Also bail out early in InsertLineBreakCommand::doApply
     10        in case position is not editable.
     11
     12        Test: editing/execCommand/insert-line-break-crash.html
     13
     14        * editing/InsertLineBreakCommand.cpp:
     15        (WebCore::InsertLineBreakCommand::shouldUseBreakElement):
     16        (WebCore::InsertLineBreakCommand::doApply):
     17
    1182021-12-06  Tadeu Zagallo  <tzagallo@apple.com>
    219
  • trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp

    r266557 r286553  
    6161    // parent's renderer.
    6262    auto* node = position.parentAnchoredEquivalent().deprecatedNode();
    63     return node->renderer() && !node->renderer()->style().preserveNewline();
     63    return node && node->renderer() && !node->renderer()->style().preserveNewline();
    6464}
    6565
     
    8282    position = positionOutsideTabSpan(position);
    8383
     84    if (!isEditablePosition(position))
     85        return;
     86
    8487    RefPtr<Node> nodeToInsert;
    8588    if (shouldUseBreakElement(position))
     
    9295    if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) {
    9396        bool needExtraLineBreak = !is<HTMLHRElement>(*position.deprecatedNode()) && !is<HTMLTableElement>(*position.deprecatedNode());
    94        
     97
    9598        insertNodeAt(*nodeToInsert, position);
    9699       
Note: See TracChangeset for help on using the changeset viewer.