mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02: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:
committed by
Jelle Raaijmakers
parent
00002c6443
commit
5f5975c81d
Notes:
github-actions[bot]
2025-06-18 11:09:39 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/5f5975c81d0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5129 Reviewed-by: https://github.com/gmta ✅
@@ -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({});
|
||||
|
||||
Reference in New Issue
Block a user