mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
LibWeb: Keep message alive in postMessage task callback lambda
Tasks can run at any time in the future and GC can run in the time between postMessage and running the task, meaning the message can be reaped if we don't keep a handle to it. Fixes Google Syndication ads crashing 100% of the time on rpcs3.net
This commit is contained in:
@@ -87,9 +87,9 @@ void MessagePort::post_message(JS::Value message)
|
||||
|
||||
// FIXME: This is an ad-hoc hack implementation instead, since we don't currently
|
||||
// have serialization and deserialization of messages.
|
||||
main_thread_event_loop().task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [strong_port = JS::make_handle(*target_port), message]() mutable {
|
||||
main_thread_event_loop().task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [strong_port = JS::make_handle(*target_port), strong_message = JS::make_handle(message)]() mutable {
|
||||
MessageEventInit event_init {};
|
||||
event_init.data = message;
|
||||
event_init.data = strong_message.value();
|
||||
event_init.origin = "<origin>";
|
||||
strong_port->dispatch_event(*MessageEvent::create(verify_cast<HTML::Window>(strong_port->realm().global_object()), HTML::EventNames::message, event_init));
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user