unix: remove handle from queue on uv_spawn() error (#4980)

If uv_spawn() fails after uv__handle_init() has been called, the handle
remains in loop->handle_queue. This causes use-after-free if the handle
is stack-allocated or freed, and a subsequent loop operation like
uv_walk() accesses it.

This follows the same pattern as uv_tcp_init_ex() which explicitly
removes the handle from the queue on error.
This commit is contained in:
Oblivionsage 2025-12-26 16:53:42 +01:00 committed by GitHub
parent 309b28bdbe
commit 3e9ae1bca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1073,6 +1073,7 @@ int uv_spawn(uv_loop_t* loop,
return exec_errorno;
error:
uv__queue_remove(&process->handle_queue);
if (pipes != NULL) {
for (i = 0; i < stdio_count; i++) {
if (i < options->stdio_count)