[前][次][番号順一覧][スレッド一覧]

ruby-changes:45747

From: nobu <ko1@a...>
Date: Thu, 9 Mar 2017 12:38:11 +0900 (JST)
Subject: [ruby-changes:45747] nobu:r57820 (trunk): goruby.c: FD leak [ci skip]

nobu	2017-03-09 12:38:06 +0900 (Thu, 09 Mar 2017)

  New Revision: 57820

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57820

  Log:
    goruby.c: FD leak [ci skip]
    
    * goruby.c (goruby_options): fix potential FD leak.

  Modified files:
    trunk/goruby.c
Index: goruby.c
===================================================================
--- goruby.c	(revision 57819)
+++ goruby.c	(revision 57820)
@@ -35,7 +35,11 @@ goruby_options(int argc, char **argv) https://github.com/ruby/ruby/blob/trunk/goruby.c#L35
     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) https://github.com/ruby/ruby/blob/trunk/goruby.c#L50
 	return ret;
     }
     else {
+      no_irb:
 	return ruby_options(argc, argv);
     }
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]