From 0fefd1902329f72434e859bd77a7ea5a114c00ff Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 13 Jul 2009 13:33:00 +0000 Subject: [PATCH] * io.c (pipe_open): handles leaked on win32 when an error occurs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ io.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41ce686725..3f63ebba08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jul 13 22:28:03 2009 NAKAMURA Usaku + + * io.c (pipe_open): handles leaked on win32 when an error occurs. + Mon Jul 13 20:21:51 2009 Nobuyoshi Nakada * marshal.c (r_object0): should not shadow outer variable not to diff --git a/io.c b/io.c index 517f02bb4c..45c4a73215 100644 --- a/io.c +++ b/io.c @@ -5034,9 +5034,19 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, rb_thread_sleep(1); break; default: - if (eargp) - rb_run_exec_options(&sarg, NULL); - rb_sys_fail(cmd); + { + int e = errno; + if (eargp) + rb_run_exec_options(&sarg, NULL); + close(pair[0]); + close(pair[1]); + if ((fmode & (FMODE_READABLE|FMODE_WRITABLE)) == (FMODE_READABLE|FMODE_WRITABLE)) { + close(write_pair[0]); + close(write_pair[1]); + } + errno = e; + rb_sys_fail(cmd); + } break; } }