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

Changeset 157219 in webkit


Ignore:
Timestamp:
Oct 10, 2013, 6:29:54 AM (13 years ago)
Author:
zandobersek@gmail.com
Message:

REGRESSION(r157210): Crashes in WebCore::ScopedEventQueue::dispatchEvent for platforms using GCC
​https://bugs.webkit.org/show_bug.cgi?id=122592

Reviewed by Gustavo Noronha Silva.

  • dom/ScopedEventQueue.cpp:

(WebCore::ScopedEventQueue::dispatchEvent): When calling EventDispatcher::dispatchEvent(), the GCC-compiled code
first creates a copy of the PassRefPtr<Event> object that's being passed into the method call. The copy will be used
in that method while the original is left with a null pointer. Only after that is the original queried for its pointer
while trying to get the Event's target, resulting in a crash due to calling the Event::target() on a null pointer.
To avoid it, pass a naked Event pointer to the method call. This will create a new PassRefPtr object without nullifying
the original one.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r157216 r157219  
     12013-10-10  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        REGRESSION(r157210): Crashes in WebCore::ScopedEventQueue::dispatchEvent for platforms using GCC
     4        https://bugs.webkit.org/show_bug.cgi?id=122592
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        * dom/ScopedEventQueue.cpp:
     9        (WebCore::ScopedEventQueue::dispatchEvent): When calling EventDispatcher::dispatchEvent(), the GCC-compiled code
     10        first creates a copy of the PassRefPtr<Event> object that's being passed into the method call. The copy will be used
     11        in that method while the original is left with a null pointer. Only after that is the original queried for its pointer
     12        while trying to get the Event's target, resulting in a crash due to calling the Event::target() on a null pointer.
     13        To avoid it, pass a naked Event pointer to the method call. This will create a new PassRefPtr object without nullifying
     14        the original one.
     15
    1162013-10-10  Andreas Kling  <akling@apple.com>
    217
  • trunk/Source/WebCore/dom/ScopedEventQueue.cpp

    r157203 r157219  
    8080{
    8181    ASSERT(event->target());
    82     EventDispatcher::dispatchEvent(event->target()->toNode(), event);
     82    // Passing a naked Event pointer instead of the PassRefPtr<Event> prevents the PassRefPtr copy
     83    // that nullifies the original PassRefPtr. This prevents crashes on GCC-compiled code since
     84    // GCC creates the copy first, which leaves the event->target() call to be made on a null pointer.
     85    EventDispatcher::dispatchEvent(event->target()->toNode(), event.get());
    8386}
    8487
Note: See TracChangeset for help on using the changeset viewer.