Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use RefPtr local variable for nextChild in insertChildrenBeforeWithou…
…tPreInsertionValidityCheck https://bugs.webkit.org/show_bug.cgi?id=268765 rdar://122122623 Reviewed by Ryosuke Niwa and Chris Dumez. This patch adds a RefPtr to hold a reference to nextChild so that the pointer stay valid through the scope of the function. In the test case, the removeChild() call (from the before() call in the js script) triggers a DOMSubtreeModified event, which eventually calls normalize. The normalize() call can destroy text elements when normalizing the content of the node if there is no one holding the reference to that node, so holding nextChild in a RefPtr prevents us from reading an invalid pointer. * LayoutTests/fast/dom/set-attribute-and-normalize-in-event-expected.txt: Added. * LayoutTests/fast/dom/set-attribute-and-normalize-in-event.html: Added. * Source/WebCore/dom/ContainerNode.cpp: (WebCore::ContainerNode::insertChildrenBeforeWithoutPreInsertionValidityCheck): Originally-landed-as: 274097.10@webkit-2024.2-embargoed (65b1fae34533). rdar://128089683 Canonical link: https://commits.webkit.org/278837@main
- Loading branch information