Skip to content

Commit c07fb79

Browse files
committed
Avoid file descriptor leak
`extra_fd` was leaked if `fd_set_cloexec` fails -- I can't think of any chance of that happening here, but just in case. Coverity Scan found this issue.
1 parent 2560242 commit c07fb79

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

process.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,7 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
33683368
// in #assert_close_on_exec because the FD_CLOEXEC is not dup'd by default
33693369
if (fd_get_cloexec(pairs[i].oldfd, errmsg, errmsg_buflen)) {
33703370
if (fd_set_cloexec(extra_fd, errmsg, errmsg_buflen)) {
3371+
close(extra_fd);
33713372
goto fail;
33723373
}
33733374
}

0 commit comments

Comments
 (0)