LibWeb: Iterate safely in HTMLSelectElement::set_value()

We can't iterate over m_cached_list_of_options and call set_selected()
in the loop, since that may end up rebuilding m_cached_list_of_options,
disrupting iteration.
This commit is contained in:
Andreas Kling 2025-05-28 11:25:20 +02:00 committed by Alexander Kalenik
parent 18d17385fb
commit 5c5283492b
Notes: github-actions[bot] 2025-05-29 01:48:10 +00:00

View file

@ -377,7 +377,7 @@ String HTMLSelectElement::value() const
WebIDL::ExceptionOr<void> HTMLSelectElement::set_value(String const& value)
{
update_cached_list_of_options();
for (auto const& option_element : m_cached_list_of_options)
for (auto const& option_element : list_of_options())
option_element->set_selected(option_element->value() == value);
update_inner_text_element();
return {};