Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fac72c776640f70077dd6f4b021916213c10709a
https://github.com/WebKit/WebKit/commit/fac72c776640f70077dd6f4b021916213c10709a
Author: Ryosuke Niwa <[email protected]>
Date: 2026-06-29 (Mon, 29 Jun 2026)
Changed paths:
A
LayoutTests/fast/forms/auto-fill-button/auto-fill-button-click-then-type-change-crash-expected.txt
A
LayoutTests/fast/forms/auto-fill-button/auto-fill-button-click-then-type-change-crash.html
M Source/WebCore/html/SearchInputType.h
M Source/WebCore/html/TextFieldInputType.cpp
M Source/WebCore/html/TextFieldInputType.h
M Source/WebCore/html/shadow/AutoFillButtonElement.cpp
M Source/WebCore/html/shadow/AutoFillButtonElement.h
Log Message:
-----------
Use-after-free in AutoFillButtonElement::defaultEventHandler
https://bugs.webkit.org/show_bug.cgi?id=313700
Reviewed by Aditya Keerthi.
AutoFillButtonElement held its AutoFillButtonOwner as a raw C++ reference. When
a click listener on the host
input element flips input.type in the middle of a click event dispatch,
HTMLInputElement::updateType()
destroys the old TextFieldInputType (the only owner), but the button is kept
alive by EventPath.
callDefaultEventHandlersInBubblingOrder then makes the virtual call
m_owner.autoFillButtonElementWasClicked()
through freed memory.
Fix mirrors the existing SpinButtonElement pattern: AutoFillButtonOwner now
derives from
AbstractRefCountedAndCanMakeWeakPtr, the back-reference is a WeakPtr that is
null-checked (and RefPtr-protected)
in defaultEventHandler, TextFieldInputType forwards ref()/deref() to InputType
and clears the back-reference
in removeShadowSubtree() via a new removeAutoFillButtonOwner().
Test:
fast/forms/auto-fill-button/auto-fill-button-click-then-type-change-crash.html
*
LayoutTests/fast/forms/auto-fill-button/auto-fill-button-click-then-type-change-crash-expected.txt:
Added.
*
LayoutTests/fast/forms/auto-fill-button/auto-fill-button-click-then-type-change-crash.html:
Added.
* Source/WebCore/html/SearchInputType.h:
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::removeShadowSubtree):
* Source/WebCore/html/TextFieldInputType.h:
* Source/WebCore/html/shadow/AutoFillButtonElement.cpp:
(WebCore::AutoFillButtonElement::defaultEventHandler):
* Source/WebCore/html/shadow/AutoFillButtonElement.h:
Originally-landed-as: 305413.807@safari-7624-branch (354642cc1251).
rdar://180428678
Canonical link: https://commits.webkit.org/316086@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications