aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/io.c b/io.c
index 6926316569..653034dd58 100644
--- a/io.c
+++ b/io.c
@@ -2372,9 +2372,6 @@ io_setstrbuf(VALUE *str, long len)
long clen = RSTRING_LEN(s);
if (clen >= len) {
rb_str_modify(s);
- if (clen != len) {
- rb_str_set_len(s, len);
- }
return;
}
len -= clen;
@@ -2902,7 +2899,10 @@ io_read(int argc, VALUE *argv, VALUE io)
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
- if (len == 0) return str;
+ if (len == 0) {
+ io_set_read_length(str, 0);
+ return str;
+ }
READ_CHECK(fptr);
#if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32)