Skip to content

Commit 3e9ae1b

Browse files
authored
unix: remove handle from queue on uv_spawn() error (libuv#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.
1 parent 309b28b commit 3e9ae1b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/unix/process.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,7 @@ int uv_spawn(uv_loop_t* loop,
10731073
return exec_errorno;
10741074

10751075
error:
1076+
uv__queue_remove(&process->handle_queue);
10761077
if (pipes != NULL) {
10771078
for (i = 0; i < stdio_count; i++) {
10781079
if (i < options->stdio_count)

0 commit comments

Comments
 (0)