summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-13 20:25:10 (GMT)
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-13 20:25:10 (GMT)
commit0ebf2afa814a82dec149c37e51e09698ea527bad (patch)
tree7016187d70c2e7d2882bedcee6821e34a801e979 /io.c
parentb1e064fc059436691fc16c6096087bb8b6b719c8 (diff)
* io.c (rb_io_s_binread): close fd if seek offset is invalid.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/io.c b/io.c
index fd8f6f1..fcccc71 100644
--- a/io.c
+++ b/io.c
@@ -9901,7 +9901,16 @@ rb_io_s_binread(int argc, VALUE *argv, VALUE io)
arg.argv = argv+1;
arg.argc = (argc > 1) ? 1 : 0;
if (!NIL_P(offset)) {
- rb_io_seek(arg.io, offset, SEEK_SET);
+ struct seek_arg sarg;
+ int state = 0;
+ sarg.io = arg.io;
+ sarg.offset = offset;
+ sarg.mode = SEEK_SET;
+ rb_protect(seek_before_access, (VALUE)&sarg, &state);
+ if (state) {
+ rb_io_close(arg.io);
+ rb_jump_tag(state);
+ }
}
return rb_ensure(io_s_read, (VALUE)&arg, rb_io_close, arg.io);
}