mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibWeb: Make a copy of Document's DocumentObserver set when iterating
The observer callbacks can do all kinds of things, so let's not be in the middle of iterating the set in case someone decides to mutate it. Fixes a crash when loading https://lichess.org/
This commit is contained in:
parent
6fb670c1c2
commit
17ba47558c
Notes:
sideshowbarker
2024-07-17 05:21:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/17ba47558c
1 changed files with 4 additions and 2 deletions
|
@ -1752,7 +1752,8 @@ void Document::completely_finish_loading()
|
|||
});
|
||||
}
|
||||
|
||||
for (auto& document_observer : m_document_observers) {
|
||||
auto observers_to_notify = m_document_observers.values();
|
||||
for (auto& document_observer : observers_to_notify) {
|
||||
if (document_observer->document_fully_loaded)
|
||||
document_observer->document_fully_loaded();
|
||||
}
|
||||
|
@ -2627,7 +2628,8 @@ void Document::did_stop_being_active_document_in_browsing_context(Badge<HTML::Br
|
|||
{
|
||||
tear_down_layout_tree();
|
||||
|
||||
for (auto& document_observer : m_document_observers) {
|
||||
auto observers_to_notify = m_document_observers.values();
|
||||
for (auto& document_observer : observers_to_notify) {
|
||||
if (document_observer->document_became_inactive)
|
||||
document_observer->document_became_inactive();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue