Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Issue 398653003: Fix possible crash in Element::normalizeAttributes() (Closed)

Created:
6 years, 5 months ago by Inactive
Modified:
6 years, 5 months ago
CC:
blink-reviews, blink-reviews-dom_chromium.org, dglazkov+blink, sof, eae+blinkwatch, rwlbuis, inferno, tkent
Project:
blink
Visibility:
Public.

Description

Fix possible crash in Element::normalizeAttributes() Fix possible crash in Element::normalizeAttributes() caused by the ElementData becoming unique while we are iterating over the Element's attributes. A call to Attr::normalize() can cause an attribute's value to be updated, thus causing the Element's ElementData to become unique if it was previously shareable. The issue is that we were iterating over the Element's attributes, which relies on the internal representation of the ElementData. When the ShareableElementData gets replaced by a UniqueElementData, the internal representation goes away and what we are iterating on no longer exists. The solution adoped in this CL is to iterate of the Element's attrNodeList() Vector instead, since what we are really interested in are Attr Nodes and not Attribute objects. The attrNodeList() method returns a pointer to a Vector stored in ElementRareData, and thus never shared between Elements. We anyway make a copy of that vector before iterating because attributes can potentially be added / removed by JS listeners while we are iterating (see fast/dom/normalize-attributes-mutation-event-crash.html layout test). BUG=394026 TEST=fast/dom/Element/normalize-crash2.html R=esprehn@chromium.org, tkent@chromium.org Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=178235

Patch Set 1 #

Patch Set 2 : Clean up #

Patch Set 3 : Fix fast/dom/normalize-attributes-mutation-event-crash.html failure #

Unified diffs Side-by-side diffs Delta from patch set Stats (+20 lines, -7 lines) Patch
A LayoutTests/fast/dom/Element/normalize-crash2.html View 1 chunk +12 lines, -0 lines 0 comments Download
A + LayoutTests/fast/dom/Element/normalize-crash2-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
M Source/core/dom/Element.cpp View 1 2 1 chunk +9 lines, -8 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Inactive
6 years, 5 months ago (2014-07-16 02:21:21 UTC) #1
tkent
lgtm
6 years, 5 months ago (2014-07-16 03:09:51 UTC) #2
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ch.dumez@samsung.com/398653003/40001
6 years, 5 months ago (2014-07-16 03:10:27 UTC) #3
commit-bot: I haz the power
6 years, 5 months ago (2014-07-16 03:14:00 UTC) #4
Message was sent while issue was closed.
Change committed as 178235

Powered by Google App Engine
This is Rietveld 408576698