summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-03 09:30:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-03 09:30:33 +0000
commit379e85a5f5b243f307b97b76a762947ffbe6bc48 (patch)
treebfbe7e40f4e9e813d4cdce3a5776da1ec41a8080 /io.c
parent744ec6294cbe29513af083bf1106b68247c72275 (diff)
* eval.c (proc_invoke): copy arguments to frame.argv.
[ruby-core:03861] * object.c (convert_type): use rb_respond_to() again. [ruby-dev:25021] * eval.c (rb_respond_to): funcall respond_to? if it's redefined. [ruby-dev:25021] * io.c (rb_file_initialize): [ruby-dev:25032] * lib/ostruct.rb (OpenStruct::Marshaler): OpenStruct can be marshaled again. [ruby-core:03862] * io.c (rb_io_ctl): [ruby-dev:25019] * io.c (io_fread): need not to null terminate. [ruby-dev:24998] * io.c (read_all): remove unnecessary rb_str_resize(). [ruby-dev:24996] * io.c (io_read): ditto. * io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/io.c b/io.c
index 04e8d57..a316436 100644
--- a/io.c
+++ b/io.c
@@ -2177,13 +2177,19 @@ rb_io_sysread(argc, argv, io)
if (READ_DATA_BUFFERED(fptr->f)) {
rb_raise(rb_eIOError, "sysread for buffered IO");
}
+ rb_str_locktmp(str);
+
n = fileno(fptr->f);
rb_thread_wait_fd(fileno(fptr->f));
rb_io_check_closed(fptr);
+ if (RSTRING(str)->len != ilen) {
+ rb_raise(rb_eRuntimeError, "buffer string modified");
+ }
TRAP_BEG;
- n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
+ n = read(fileno(fptr->f), RSTRING(str)->ptr, ilen);
TRAP_END;
+ rb_str_unlocktmp(str);
if (n == -1) {
rb_sys_fail(fptr->path);
}
@@ -3867,9 +3873,7 @@ rb_file_initialize(argc, argv, io)
VALUE io;
{
if (RFILE(io)->fptr) {
- rb_io_close_m(io);
- free(RFILE(io)->fptr);
- RFILE(io)->fptr = 0;
+ rb_raise(rb_eRuntimeError, "reinitializing File");
}
if (0 < argc && argc < 3) {
VALUE fd = rb_check_convert_type(argv[0], T_FIXNUM, "Fixnum", "to_int");
@@ -4477,7 +4481,6 @@ rb_io_ctl(io, req, arg, io_p)
int retval;
rb_secure(2);
- GetOpenFile(io, fptr);
if (NIL_P(arg) || arg == Qfalse) {
narg = 0;
@@ -4518,6 +4521,7 @@ rb_io_ctl(io, req, arg, io_p)
narg = (long)RSTRING(arg)->ptr;
}
}
+ GetOpenFile(io, fptr);
retval = io_cntl(fileno(fptr->f), cmd, narg, io_p);
if (retval < 0) rb_sys_fail(fptr->path);
if (TYPE(arg) == T_STRING && RSTRING(arg)->ptr[len] != 17) {