summaryrefslogtreecommitdiff
path: root/goruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-09 03:38:06 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-09 03:38:06 (GMT)
commita3c23f0074eaece71bac838af0e32e366ae0d760 (patch)
tree24d6fa530a96571b212d34efa07dc8475d4b2bff /goruby.c
parentf861c4d40e27fa30298aa874a6682f8a9462c5e0 (diff)
goruby.c: FD leak [ci skip]
* 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
Diffstat (limited to 'goruby.c')
-rw-r--r--goruby.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/goruby.c b/goruby.c
index 5ac4c96..ddb6256 100644
--- a/goruby.c
+++ b/goruby.c
@@ -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);
@@ -46,6 +50,7 @@ goruby_options(int argc, char **argv)
return ret;
}
else {
+ no_irb:
return ruby_options(argc, argv);
}
}