inspector: fix crash when writing to closed inspector socket · nodejs/node@eb2e96b · GitHub
Skip to content

Commit eb2e96b

Browse files
Yayapaparichardlau
authored andcommitted
inspector: fix crash when writing to closed inspector socket
ProtocolHandler::WriteRaw() dereferences tcp_ without a null check. When the remote end disconnects, OnEof() resets tcp_ to nullptr, but queued messages from the uv_async callback can still trigger Write() on the same event loop iteration, causing a null pointer dereference crash (EXCEPTION_ACCESS_VIOLATION on Windows). Additionally, ParseWsFrames() can call OnEof() internally (on compressed or error frames), which resets tcp_ mid-loop in OnData(). If the delegate callback triggered by OnWsFrame() then calls Write(), it would also hit the null tcp_ crash. Add null guards in: - WsHandler::OnData: stop parsing loop when tcp_ becomes null - WsHandler::Write: early return before frame encoding - ProtocolHandler::WriteRaw: defensive fallback for all write paths Fixes: #34833 Signed-off-by: piaoyingmin <piaoyingmin@bytedance.com> PR-URL: #64209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
1 parent a22a840 commit eb2e96b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/inspector_socket.cc

Lines changed: 3 additions & 1 deletion

0 commit comments

Comments
 (0)