mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
LibWeb: Reset message port receive state before dispatching events
Dispatching events can cause arbitrary JS to run, which could cause the event loop to be re-entered, or even post another message to the same message port.
This commit is contained in:
committed by
Andreas Kling
parent
09ce32039f
commit
5ace712282
@@ -297,8 +297,11 @@ void MessagePort::read_from_socket()
|
||||
|
||||
auto serialize_with_transfer_result = MUST(decoder.decode<SerializedTransferRecord>());
|
||||
|
||||
post_message_task_steps(serialize_with_transfer_result);
|
||||
// Make sure to advance our state machine before dispatching the MessageEvent,
|
||||
// as dispatching events can run arbitrary JS (and cause us to receive another message!)
|
||||
m_socket_state = SocketState::Header;
|
||||
|
||||
post_message_task_steps(serialize_with_transfer_result);
|
||||
break;
|
||||
}
|
||||
case SocketState::Error:
|
||||
|
||||
Reference in New Issue
Block a user