mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +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:
parent
09ce32039f
commit
5ace712282
1 changed files with 4 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue