Changeset 167818 in webkit


Ignore:
Timestamp:
Apr 25, 2014 1:30:07 PM (10 years ago)
Author:
jhoneycutt@apple.com
Message:

Crash applying editing commands from iframe onload event

<https://bugs.webkit.org/show_bug.cgi?id=132103>
<rdar://problem/15696351>

Source/WebCore:
This patch merges the Chromium bug workaround from
<http://src.chromium.org/viewvc/blink?revision=162080&view=revision>,
which prevents reentrancy in CompositeEditCommand::apply().

Reviewed by Darin Adler.

Test: editing/apply-style-iframe-crash.html

  • editing/CompositeEditCommand.cpp:

(WebCore::HTMLNames::ReentrancyGuard::isRecursiveCall):
(WebCore::HTMLNames::ReentrancyGuard::Scope::Scope):
(WebCore::HTMLNames::ReentrancyGuard::Scope::~Scope):
(WebCore::CompositeEditCommand::apply):
If this is a recursive call, return early.

LayoutTests:
Reviewed by Darin Adler.

  • editing/apply-style-iframe-crash-expected.txt: Added.
  • editing/apply-style-iframe-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r167817 r167818  
     12014-04-23  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Crash applying editing commands from iframe onload event
     4
     5        <https://bugs.webkit.org/show_bug.cgi?id=132103>
     6        <rdar://problem/15696351>
     7
     8        Reviewed by Darin Adler.
     9
     10        * editing/apply-style-iframe-crash-expected.txt: Added.
     11        * editing/apply-style-iframe-crash.html: Added.
     12
    1132014-04-25  David Hyatt  <hyatt@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r167817 r167818  
     12014-04-23  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Crash applying editing commands from iframe onload event
     4
     5        <https://bugs.webkit.org/show_bug.cgi?id=132103>
     6        <rdar://problem/15696351>
     7
     8        This patch merges the Chromium bug workaround from
     9        <http://src.chromium.org/viewvc/blink?revision=162080&view=revision>,
     10        which prevents reentrancy in CompositeEditCommand::apply().
     11
     12        Reviewed by Darin Adler.
     13
     14        Test: editing/apply-style-iframe-crash.html
     15
     16        * editing/CompositeEditCommand.cpp:
     17        (WebCore::HTMLNames::ReentrancyGuard::isRecursiveCall):
     18        (WebCore::HTMLNames::ReentrancyGuard::Scope::Scope):
     19        (WebCore::HTMLNames::ReentrancyGuard::Scope::~Scope):
     20        (WebCore::CompositeEditCommand::apply):
     21        If this is a recursive call, return early.
     22
    1232014-04-25  David Hyatt  <hyatt@apple.com>
    224
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r165848 r167818  
    8181using namespace HTMLNames;
    8282
     83namespace ApplyEditCommand {
     84   
     85class ReentrancyGuard {
     86public:
     87    static bool isRecursiveCall() { return s_nestingCounter; }
     88
     89    class Scope {
     90    public:
     91        Scope() { ++s_nestingCounter; }
     92        ~Scope() { --s_nestingCounter; }
     93    };
     94    friend class Scope;
     95
     96private:
     97    static unsigned s_nestingCounter;
     98};
     99unsigned ApplyEditCommand::ReentrancyGuard::s_nestingCounter;
     100   
     101} // namespace ApplyEditCommand
     102
    83103PassRefPtr<EditCommandComposition> EditCommandComposition::create(Document& document,
    84104    const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction editAction)
     
    195215void CompositeEditCommand::apply()
    196216{
     217    // It's possible to enter this recursively, but legitimate cases of that are rare, and it can cause crashes. As a
     218    // temporary fix, guard against recursive calls.
     219    // FIXME: <rdar://16701803> Remove this workaround when <rdar://15797536> is fixed.
     220    if (ApplyEditCommand::ReentrancyGuard::isRecursiveCall())
     221        return;
     222
    197223    if (!endingSelection().isContentRichlyEditable()) {
    198224        switch (editingAction()) {
     
    221247
    222248    {
    223         EventQueueScope scope;
     249        EventQueueScope eventQueueScope;
     250        ApplyEditCommand::ReentrancyGuard::Scope reentrancyGuardScope;
    224251#if ENABLE(DELETION_UI)
    225252        DeleteButtonControllerDisableScope deleteButtonControllerDisableScope(&frame());
Note: See TracChangeset for help on using the changeset viewer.