Changeset 247734 in webkit


Ignore:
Timestamp:
Jul 23, 2019, 12:50:17 PM (6 years ago)
Author:
Simon Fraser
Message:

Fix crashes in ScrollingStateNode::insertChild()
https://bugs.webkit.org/show_bug.cgi?id=200023
rdar://problem/53265378

Reviewed by Darin Adler.

Crash data suggest that ScrollingStateNode::insertChild() can be passed an index that
is larger than the size of the vector, causing crashes.

Fix defensively by falling back to append() if the passed index is equal to or larger
than the size of the children vector.

  • page/scrolling/ScrollingStateNode.cpp:

(WebCore::ScrollingStateNode::insertChild):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247730 r247734  
    229229
    230230        * Scripts/SettingsTemplates/Settings.cpp.erb:
     231
     2322019-07-22  Simon Fraser  <simon.fraser@apple.com>
     233
     234        Fix crashes in ScrollingStateNode::insertChild()
     235        https://bugs.webkit.org/show_bug.cgi?id=200023
     236        rdar://problem/53265378
     237
     238        Reviewed by Darin Adler.
     239
     240        Crash data suggest that ScrollingStateNode::insertChild() can be passed an index that
     241        is larger than the size of the vector, causing crashes.
     242
     243        Fix defensively by falling back to append() if the passed index is equal to or larger
     244        than the size of the children vector.
     245
     246        * page/scrolling/ScrollingStateNode.cpp:
     247        (WebCore::ScrollingStateNode::insertChild):
    231248
    2322492019-07-22  Simon Fraser  <simon.fraser@apple.com>
  • trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp

    r246913 r247734  
    117117    }
    118118
    119     m_children->insert(index, WTFMove(childNode));
     119    if (index > m_children->size()) {
     120        ASSERT_NOT_REACHED();  // Crash data suggest we can get here.
     121        m_children->append(WTFMove(childNode));
     122    } else
     123        m_children->insert(index, WTFMove(childNode));
     124   
    120125    setPropertyChanged(ChildNodes);
    121126}
Note: See TracChangeset for help on using the changeset viewer.