Changeset 236446 in webkit


Ignore:
Timestamp:
Sep 24, 2018 5:28:42 PM (6 years ago)
Author:
rniwa@webkit.org
Message:

Don't cause a crash even when some IDL attribute is missing CEReactions
https://bugs.webkit.org/show_bug.cgi?id=189937

Reviewed by Simon Fraser.

Replaced release assertions in ElementQueue::add and ElementQueue::invokeAll by debug assertions
since a missing CEReactions resulting in a crash is a terrible user experience.

Also made the iteration in invokeAll safe when more elements were added to m_elements.

No new tests since we would still hit debug assertions, and this behavior should only come up
when some IDL attribute is erroneously missing CEReactions.

  • dom/CustomElementReactionQueue.cpp:

(WebCore::CustomElementReactionQueue::ElementQueue::add):
(WebCore::CustomElementReactionQueue::ElementQueue::invokeAll):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r236445 r236446  
     12018-09-24  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Don't cause a crash even when some IDL attribute is missing CEReactions
     4        https://bugs.webkit.org/show_bug.cgi?id=189937
     5
     6        Reviewed by Simon Fraser.
     7
     8        Replaced release assertions in ElementQueue::add and ElementQueue::invokeAll by debug assertions
     9        since a missing CEReactions resulting in a crash is a terrible user experience.
     10
     11        Also made the iteration in invokeAll safe when more elements were added to m_elements.
     12
     13        No new tests since we would still hit debug assertions, and this behavior should only come up
     14        when some IDL attribute is erroneously missing CEReactions.
     15
     16        * dom/CustomElementReactionQueue.cpp:
     17        (WebCore::CustomElementReactionQueue::ElementQueue::add):
     18        (WebCore::CustomElementReactionQueue::ElementQueue::invokeAll):
     19
    1202018-09-24  Wenson Hsieh  <wenson_hsieh@apple.com>
    221
  • trunk/Source/WebCore/dom/CustomElementReactionQueue.cpp

    r236376 r236446  
    226226inline void CustomElementReactionQueue::ElementQueue::add(Element& element)
    227227{
    228     RELEASE_ASSERT(!m_invoking);
     228    ASSERT(!m_invoking);
    229229    // FIXME: Avoid inserting the same element multiple times.
    230230    m_elements.append(element);
     
    235235    RELEASE_ASSERT(!m_invoking);
    236236    SetForScope<bool> invoking(m_invoking, true);
    237     auto originalSize = m_elements.size();
    238     for (auto& element : m_elements) {
    239         auto* queue = element->reactionQueue();
     237    unsigned originalSize = m_elements.size();
     238    // It's possible for more elements to be enqueued if some IDL attributes were missing CEReactions.
     239    // Invoke callbacks slightly later here instead of crashing / ignoring those cases.
     240    for (unsigned i = 0; i < m_elements.size(); ++i) {
     241        auto& element = m_elements[i].get();
     242        auto* queue = element.reactionQueue();
    240243        ASSERT(queue);
    241         queue->invokeAll(element.get());
    242     }
    243     RELEASE_ASSERT(m_elements.size() == originalSize);
     244        queue->invokeAll(element);
     245    }
     246    ASSERT_UNUSED(originalSize, m_elements.size() == originalSize);
    244247    m_elements.clear();
    245248}
Note: See TracChangeset for help on using the changeset viewer.