Skip to content

Commit

Permalink
goruby.c: FD leak [ci skip]
Browse files Browse the repository at this point in the history
* goruby.c (goruby_options): fix potential FD leak.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Mar 9, 2017
1 parent f861c4d commit a3c23f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion goruby.c
Expand Up @@ -35,7 +35,11 @@ goruby_options(int argc, char **argv)
if ((isatty(0) && isatty(1) && isatty(2)) && (pipe(rw) == 0)) {
ssize_t n;
infd = dup(0);
if (infd < 0) return NULL;
if (infd < 0) {
close(rw[0]);
close(rw[1]);
goto no_irb;
}
dup2(rw[0], 0);
close(rw[0]);
n = write(rw[1], cmd, sizeof(cmd) - 1);
Expand All @@ -46,6 +50,7 @@ goruby_options(int argc, char **argv)
return ret;
}
else {
no_irb:
return ruby_options(argc, argv);
}
}
Expand Down

0 comments on commit a3c23f0

Please sign in to comment.