From 5c5283492bb449ed8eeecc2a9f9f8fbb2305eb98 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 28 May 2025 11:25:20 +0200 Subject: [PATCH] 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. --- Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index d4854f24030..8c7503cc876 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -377,7 +377,7 @@ String HTMLSelectElement::value() const WebIDL::ExceptionOr 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 {};