Changeset 178363 in webkit


Ignore:
Timestamp:
Jan 13, 2015 8:59:49 AM (9 years ago)
Author:
akling@apple.com
Message:

Element::normalizeAttributes() needs to handle arbitrary JS executing between loop iterations.
<https://webkit.org/b/140379>
<rdar://problem/19446901>

Reviewed by Benjamin Poulain.

Source/WebCore:

Since DOM mutation events may arise below the call to Node::normalize(),
have the loop in Element::normalizeAttributes() make a copy of the Attr nodes
beforehand, to guard against mutations.

Based on a patch by Chris "Chris Dumez" Dumez.

Test: fast/dom/Element/normalize-crash2.html

  • dom/Element.cpp:

(WebCore::Element::normalizeAttributes):

LayoutTests:

  • fast/dom/Element/normalize-crash2-expected.txt: Added.
  • fast/dom/Element/normalize-crash2.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r178362 r178363  
     12015-01-13  Andreas Kling  <akling@apple.com>
     2
     3        Element::normalizeAttributes() needs to handle arbitrary JS executing between loop iterations.
     4        <https://webkit.org/b/140379>
     5        <rdar://problem/19446901>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        * fast/dom/Element/normalize-crash2-expected.txt: Added.
     10        * fast/dom/Element/normalize-crash2.html: Added.
     11
    1122015-01-13  Andrzej Badowski  <a.badowski@samsung.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r178349 r178363  
     12015-01-13  Andreas Kling  <akling@apple.com>
     2
     3        Element::normalizeAttributes() needs to handle arbitrary JS executing between loop iterations.
     4        <https://webkit.org/b/140379>
     5        <rdar://problem/19446901>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        Since DOM mutation events may arise below the call to Node::normalize(),
     10        have the loop in Element::normalizeAttributes() make a copy of the Attr nodes
     11        beforehand, to guard against mutations.
     12
     13        Based on a patch by Chris "Chris Dumez" Dumez.
     14
     15        Test: fast/dom/Element/normalize-crash2.html
     16
     17        * dom/Element.cpp:
     18        (WebCore::Element::normalizeAttributes):
     19
    1202015-01-13  Shivakumar JM  <shiva.jm@samsung.com>
    221
  • trunk/Source/WebCore/dom/Element.cpp

    r178048 r178363  
    23142314    if (!hasAttributes())
    23152315        return;
    2316     for (const Attribute& attribute : attributesIterator()) {
    2317         if (RefPtr<Attr> attr = attrIfExists(attribute.name()))
    2318             attr->normalize();
    2319     }
     2316
     2317    auto* attrNodeList = attrNodeListForElement(*this);
     2318    if (!attrNodeList)
     2319        return;
     2320
     2321    // Copy the Attr Vector because Node::normalize() can fire synchronous JS
     2322    // events (e.g. DOMSubtreeModified) and a JS listener could add / remove
     2323    // attributes while we are iterating.
     2324    auto copyOfAttrNodeList = *attrNodeList;
     2325    for (auto& attrNode : copyOfAttrNodeList)
     2326        attrNode->normalize();
    23202327}
    23212328
Note: See TracChangeset for help on using the changeset viewer.