Changeset 40804 in webkit


Ignore:
Timestamp:
Feb 9, 2009 7:13:06 PM (15 years ago)
Author:
mrowe@apple.com
Message:

Fix <https://bugs.webkit.org/show_bug.cgi?id=23858>
Bug 23858: Crash when removing a HTMLSelectElement from the document from inside its focus event handler

Reviewed by Darin Adler.

  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::menuListDefaultEventHandler): Don't store the renderer in a local variable
as it can be invalidated by any of the calls to focus() within the function. Instead, retrieve it and
null-check it when it is needed.

Test for <https://bugs.webkit.org/show_bug.cgi?id=23858>
Bug 23858: Crash when removing a HTMLSelectElement from the document from inside its focus event handler

Reviewed by Sam Weinig.

  • fast/dom/HTMLSelectElement/remove-element-from-within-focus-handler-crash-expected.txt: Added.
  • fast/dom/HTMLSelectElement/remove-element-from-within-focus-handler-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r40792 r40804  
     12009-02-09  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Test for <https://bugs.webkit.org/show_bug.cgi?id=23858>
     6        Bug 23858: Crash when removing a HTMLSelectElement from the document from inside its focus event handler
     7
     8        * fast/dom/HTMLSelectElement/remove-element-from-within-focus-handler-crash-expected.txt: Added.
     9        * fast/dom/HTMLSelectElement/remove-element-from-within-focus-handler-crash.html: Added.
     10
    1112009-02-09  Dimitri Glazkov  <dglazkov@chromium.org>
    212
  • trunk/WebCore/ChangeLog

    r40802 r40804  
     12009-02-09  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Fix <https://bugs.webkit.org/show_bug.cgi?id=23858>
     6        Bug 23858: Crash when removing a HTMLSelectElement from the document from inside its focus event handler
     7
     8        * html/HTMLSelectElement.cpp:
     9        (WebCore::HTMLSelectElement::menuListDefaultEventHandler): Don't store the renderer in a local variable
     10        as it can be invalidated by any of the calls to focus() within the function.  Instead, retrieve it and
     11        null-check it when it is needed.
     12
    1132009-02-09  David Hyatt  <hyatt@apple.com>
    214
  • trunk/WebCore/html/HTMLSelectElement.cpp

    r40763 r40804  
    618618void HTMLSelectElement::menuListDefaultEventHandler(Event* evt)
    619619{
    620     RenderMenuList* menuList = static_cast<RenderMenuList*>(renderer());
    621 
    622620    if (evt->type() == eventNames().keydownEvent) {
    623621        if (!renderer() || !evt->isKeyboardEvent())
     
    631629            // which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu.
    632630            saveLastSelection();
    633             menuList->showPopup();
     631            if (RenderMenuList* menuList = static_cast<RenderMenuList*>(renderer()))
     632                menuList->showPopup();
    634633            handled = true;
    635634        }
     
    673672            // which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu.
    674673            saveLastSelection();
    675             menuList->showPopup();
     674            if (RenderMenuList* menuList = static_cast<RenderMenuList*>(renderer()))
     675                menuList->showPopup();
    676676            handled = true;
    677677        }
     
    696696    if (evt->type() == eventNames().mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
    697697        focus();
    698         if (menuList->popupIsVisible())
    699             menuList->hidePopup();
    700         else {
    701             // Save the selection so it can be compared to the new selection when we call onChange during setSelectedIndex,
    702             // which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu.
    703             saveLastSelection();
    704             menuList->showPopup();
     698        if (RenderMenuList* menuList = static_cast<RenderMenuList*>(renderer())) {
     699            if (menuList->popupIsVisible())
     700                menuList->hidePopup();
     701            else {
     702                // Save the selection so it can be compared to the new selection when we call onChange during setSelectedIndex,
     703                // which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu.
     704                saveLastSelection();
     705                menuList->showPopup();
     706            }
    705707        }
    706708        evt->setDefaultHandled();
Note: See TracChangeset for help on using the changeset viewer.