From 096d5338bdc7d412538d4a6f2e3847ec2c36a062 Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 25 Dec 2008 09:58:18 +0000 Subject: merges r20990 from trunk into ruby_1_9_1. * io.c (rb_io_initialize): check fd validity. [ruby-dev:36646] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index cd5de69f10..d157f8d83d 100644 --- a/io.c +++ b/io.c @@ -5898,6 +5898,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io) int fd, fmode, oflags = O_RDONLY; convconfig_t convconfig; VALUE opt; + struct stat st; rb_secure(4); @@ -5906,6 +5907,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io) rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &fmode, &convconfig); fd = NUM2INT(fnum); + if (fstat(fd, &st) == -1) rb_sys_fail(0); UPDATE_MAXFD(fd); if (NIL_P(vmode)) { #if defined(HAVE_FCNTL) && defined(F_GETFL) -- cgit v1.2.3