summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
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 195392e565..289242d9b1 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) {