⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269797 in webkit


Ignore:
Timestamp:
Nov 13, 2020, 2:17:17 PM (6 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r269321. rdar://problem/71083861

Protect against HTMLMediaElement being destroyed during disptachEvent().
https://bugs.webkit.org/show_bug.cgi?id=218398
<rdar://problem/67613836>

Reviewed by Chris Dumez.

Make the MainThreadGenericEventQueue protect the target as well as the owner of the queue.

Drive-by fix: Create the scoped eventFiringScope object after the protect object, to ensure
that the member variable set by the first scope will safely occur.

Drive-by fix #2: Also null-check the result of document().page() within HTMLMediaElement::dispatchEvent().

  • dom/GenericEventQueue.cpp: (WebCore::MainThreadGenericEventQueue::dispatchOneEvent):
  • html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::dispatchEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269321 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-610-branch/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-610-branch/Source/WebCore/ChangeLog

    r269796 r269797  
     12020-11-13  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r269321. rdar://problem/71083861
     4
     5    Protect against HTMLMediaElement being destroyed during disptachEvent().
     6    https://bugs.webkit.org/show_bug.cgi?id=218398
     7    <rdar://problem/67613836>
     8   
     9    Reviewed by Chris Dumez.
     10   
     11    Make the MainThreadGenericEventQueue protect the target as well as the owner of the queue.
     12   
     13    Drive-by fix: Create the scoped `eventFiringScope` object after the `protect` object, to ensure
     14    that the member variable set by the first scope will safely occur.
     15   
     16    Drive-by fix #2: Also null-check the result of document().page() within HTMLMediaElement::dispatchEvent().
     17   
     18    * dom/GenericEventQueue.cpp:
     19    (WebCore::MainThreadGenericEventQueue::dispatchOneEvent):
     20    * html/HTMLMediaElement.cpp:
     21    (WebCore::HTMLMediaElement::dispatchEvent):
     22   
     23    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     24
     25    2020-11-03  Jer Noble  <jer.noble@apple.com>
     26
     27            Protect against HTMLMediaElement being destroyed during disptachEvent().
     28            https://bugs.webkit.org/show_bug.cgi?id=218398
     29            <rdar://problem/67613836>
     30
     31            Reviewed by Chris Dumez.
     32
     33            Make the MainThreadGenericEventQueue protect the target as well as the owner of the queue.
     34
     35            Drive-by fix: Create the scoped `eventFiringScope` object after the `protect` object, to ensure
     36            that the member variable set by the first scope will safely occur.
     37
     38            Drive-by fix #2: Also null-check the result of document().page() within HTMLMediaElement::dispatchEvent().
     39
     40            * dom/GenericEventQueue.cpp:
     41            (WebCore::MainThreadGenericEventQueue::dispatchOneEvent):
     42            * html/HTMLMediaElement.cpp:
     43            (WebCore::HTMLMediaElement::dispatchEvent):
     44
    1452020-11-13  Russell Epstein  <repstein@apple.com>
    246
  • branches/safari-610-branch/Source/WebCore/dom/GenericEventQueue.cpp

    r259299 r269797  
    6565    ASSERT(!m_pendingEvents.isEmpty());
    6666
     67    Ref<EventTarget> protect(m_owner);
    6768    SetForScope<bool> eventFiringScope(m_isFiringEvent, true);
    68     Ref<EventTarget> protect(m_owner);
    6969
    7070    RefPtr<Event> event = m_pendingEvents.takeFirst();
    71     EventTarget& target = event->target() ? *event->target() : m_owner;
    72     ASSERT_WITH_MESSAGE(!target.scriptExecutionContext()->activeDOMObjectsAreStopped(),
     71    Ref<EventTarget> target = event->target() ? *event->target() : m_owner;
     72    ASSERT_WITH_MESSAGE(!target->scriptExecutionContext()->activeDOMObjectsAreStopped(),
    7373        "An attempt to dispatch an event on a stopped target by EventTargetInterface=%d (nodeName=%s target=%p owner=%p)",
    74         m_owner.eventTargetInterface(), m_owner.isNode() ? static_cast<Node&>(m_owner).nodeName().ascii().data() : "", &target, &m_owner);
    75     target.dispatchEvent(*event);
     74        m_owner.eventTargetInterface(), m_owner.isNode() ? static_cast<Node&>(m_owner).nodeName().ascii().data() : "", target.ptr(), &m_owner);
     75    target->dispatchEvent(*event);
    7676}
    7777
Note: See TracChangeset for help on using the changeset viewer.