summaryrefslogtreecommitdiff
path: root/ext/stringio
diff options
context:
space:
mode:
Diffstat (limited to 'ext/stringio')
-rw-r--r--ext/stringio/stringio.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 0fb60069de..725b5be192 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -866,10 +866,12 @@ strio_read(argc, argv, self)
rb_raise(rb_eArgError, "wrong number arguments (%d for 0)", argc);
}
str = rb_str_substr(ptr->string, ptr->pos, len);
- if (len > 0 &&
- (NIL_P(str) || (ptr->pos += RSTRING(str)->len) >= RSTRING(ptr->string)->len)) {
+ if (NIL_P(str)) {
ptr->flags |= STRIO_EOF;
}
+ else {
+ ptr->pos += RSTRING(str)->len;
+ }
return str;
}