summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-10 07:17:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-10 07:17:53 +0000
commitc5789b5075969d314b74014f02c8538e4ae25ebd (patch)
tree75c314d2451167e53fd86dca2039d096e3209802 /io.c
parentdd65b46d652d21325e9f09b1283d56303b992e8f (diff)
* dir.c (rb_glob2): do not allocate buffer from heap to avoid
memory leaks. use string object for buffering instead. [ruby-dev:24738] * dir.c (join_path): ditto. * io.c (io_read): external input buffer may be modified even after rb_str_locktmp(). [ruby-dev:24735] * dir.c (fnmatch): p or s may be NULL. [ruby-dev:24749] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/io.c b/io.c
index 195392e..289242d 100644
--- a/io.c
+++ b/io.c
@@ -320,7 +320,9 @@ io_fflush(f, fptr)
rb_io_check_closed(fptr);
}
for (;;) {
+ TRAP_BEG;
n = fflush(f);
+ TRAP_END;
if (n != EOF) break;
if (!rb_io_wait_writable(fileno(f)))
rb_sys_fail(fptr->path);
@@ -1084,6 +1086,9 @@ io_read(argc, argv, io)
rb_str_locktmp(str);
READ_CHECK(fptr->f);
+ if (RSTRING(str)->len != len) {
+ rb_raise(rb_eRuntimeError, "buffer string modified");
+ }
n = rb_io_fread(RSTRING(str)->ptr, len, fptr->f);
rb_str_unlocktmp(str);
if (n == 0) {