aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/io.c b/io.c
index ccd019f4f1..71273ed0b6 100644
--- a/io.c
+++ b/io.c
@@ -1194,11 +1194,13 @@ io_read(argc, argv, io)
StringValue(str);
rb_str_modify(str);
rb_str_resize(str,len);
+ FL_SET(str, FL_FREEZE);
}
if (len == 0) return str;
READ_CHECK(fptr->f);
n = rb_io_fread(RSTRING(str)->ptr, len, fptr->f);
+ FL_UNSET(str, FL_FREEZE);
if (n == 0) {
rb_str_resize(str,0);
if (!fptr->f) return Qnil;
@@ -2972,7 +2974,9 @@ rb_io_s_popen(argc, argv, klass)
mode = rb_io_modenum_mode(FIX2INT(pmode), mbuf);
}
else {
- mode = StringValuePtr(pmode);
+ strncpy(mbuf, StringValuePtr(pmode), sizeof(mbuf) - 1);
+ mbuf[sizeof(mbuf) - 1] = 0;
+ mode = mbuf;
}
tmp = rb_check_array_type(pname);
if (!NIL_P(tmp)) {