Changeset 102639 in webkit


Ignore:
Timestamp:
Dec 12, 2011 4:48:36 PM (12 years ago)
Author:
adamk@chromium.org
Message:

Don't crash in StyleAttributeMutationScope if the style declaration's element has been GCed
https://bugs.webkit.org/show_bug.cgi?id=74321

Reviewed by Ryosuke Niwa.

Source/WebCore:

In r101101, Rafael Weinstein added code to CSSMutableStyleDeclaration.cpp
which depended on isInlineStyleDeclaration returning true iff the
element it pointed to was non-null (it will be nulled-out if the
element is garbage collected).

Then, in r101172, Andreas Kling changed the semantics so that
isInlineStyleDeclaration only described the type of the declaration,
not the state of the related element.

This change updates Rafael's code with an explicit check that the
element is still alive.

Test: fast/dom/css-inline-style-declaration-crash.html

  • css/CSSMutableStyleDeclaration.cpp:

LayoutTests:

  • fast/dom/css-inline-style-declaration-crash-expected.txt: Added.
  • fast/dom/css-inline-style-declaration-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r102635 r102639  
     12011-12-12  Adam Klein  <adamk@chromium.org>
     2
     3        Don't crash in StyleAttributeMutationScope if the style declaration's element has been GCed
     4        https://bugs.webkit.org/show_bug.cgi?id=74321
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * fast/dom/css-inline-style-declaration-crash-expected.txt: Added.
     9        * fast/dom/css-inline-style-declaration-crash.html: Added.
     10
    1112011-12-12  Brent Fulgham  <bfulgham@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r102634 r102639  
     12011-12-12  Adam Klein  <adamk@chromium.org>
     2
     3        Don't crash in StyleAttributeMutationScope if the style declaration's element has been GCed
     4        https://bugs.webkit.org/show_bug.cgi?id=74321
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        In r101101, Rafael Weinstein added code to CSSMutableStyleDeclaration.cpp
     9        which depended on isInlineStyleDeclaration returning true iff the
     10        element it pointed to was non-null (it will be nulled-out if the
     11        element is garbage collected).
     12
     13        Then, in r101172, Andreas Kling changed the semantics so that
     14        isInlineStyleDeclaration only described the type of the declaration,
     15        not the state of the related element.
     16
     17        This change updates Rafael's code with an explicit check that the
     18        element is still alive.
     19
     20        Test: fast/dom/css-inline-style-declaration-crash.html
     21
     22        * css/CSSMutableStyleDeclaration.cpp:
     23
    1242011-12-12  Chris Fleizach  <cfleizach@apple.com>
    225
  • trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp

    r102543 r102639  
    6868
    6969        CSSInlineStyleDeclaration* inlineDecl = toCSSInlineStyleDeclaration(s_currentDecl);
     70        if (!inlineDecl->element())
     71            return;
     72
    7073        m_mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(inlineDecl->element(), HTMLNames::styleAttr);
    7174        if (m_mutationRecipients->isEmpty()) {
     
    99102        s_currentDecl = 0;
    100103        s_shouldNotifyInspector = false;
    101         if (inlineDecl->element()->document())
     104        if (inlineDecl->element() && inlineDecl->element()->document())
    102105            InspectorInstrumentation::didInvalidateStyleAttr(inlineDecl->element()->document(), inlineDecl->element());
    103106    }
Note: See TracChangeset for help on using the changeset viewer.