summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2024-11-29 02:38:49 +0900
committerYusuke Endoh <[email protected]>2024-12-18 11:10:05 +0900
commitc07fb791504cdfa32ff1be165758fcc624b26c2d (patch)
treee654691c02fba352ebd77cd3d4fabf9e83d2002d /process.c
parent25602421fb1f451746e25cc1a80b815a556be4a2 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12201
Diffstat (limited to 'process.c')
-rw-r--r--process.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/process.c b/process.c
index 786ac6ca24..5fbc9be022 100644
--- a/process.c
+++ b/process.c
@@ -3368,6 +3368,7 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
// in #assert_close_on_exec because the FD_CLOEXEC is not dup'd by default
if (fd_get_cloexec(pairs[i].oldfd, errmsg, errmsg_buflen)) {
if (fd_set_cloexec(extra_fd, errmsg, errmsg_buflen)) {
+ close(extra_fd);
goto fail;
}
}