mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-09 02:21:53 +00:00
LibWeb/HTML: Iterate safely in perform_a_microtask_checkpoint()
This list we are iterating over is removed from when there are no more GC references to an ESO. This may be triggered by a GC allocation. Since UniversalGlobalScopeMixin::notify_about_rejected_promises performs GC allocations (by, for example, allocating a GC function), it is not safe to simply iterate over this list. Fix this by taking a strong reference to all registered ESOs by copying them across to a RootVector before iteration. Fixes: #4652
This commit is contained in:
parent
00002c6443
commit
5f5975c81d
Notes:
github-actions[bot]
2025-06-18 11:09:39 +00:00
Author: https://github.com/shannonbooth
Commit: 5f5975c81d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5129
Reviewed-by: https://github.com/gmta ✅
1 changed files with 2 additions and 1 deletions
|
@ -594,7 +594,8 @@ void EventLoop::perform_a_microtask_checkpoint()
|
|||
}
|
||||
|
||||
// 4. For each environment settings object settingsObject whose responsible event loop is this event loop, notify about rejected promises given settingsObject's global object.
|
||||
for (auto& environment_settings_object : m_related_environment_settings_objects) {
|
||||
auto environments = GC::RootVector { heap(), m_related_environment_settings_objects };
|
||||
for (auto& environment_settings_object : environments) {
|
||||
auto* global = dynamic_cast<HTML::UniversalGlobalScopeMixin*>(&environment_settings_object->global_object());
|
||||
VERIFY(global);
|
||||
global->notify_about_rejected_promises({});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue