1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
eregon 2015-06-13 20:25:10 +00:00
parent b1e064fc05
commit 0ebf2afa81
2 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Sun Jun 14 05:23:51 2015 Benoit Daloze <eregontp@gmail.com>
* io.c (rb_io_s_binread): close fd if seek offset is invalid.
Sun Jun 14 04:40:32 2015 Benoit Daloze <eregontp@gmail.com>
* test/lib/leakchecker.rb (check): refactor.

11
io.c
View file

@ -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);
}