summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/marshal.c b/marshal.c
index d8f8e25926..46b0447214 100644
--- a/marshal.c
+++ b/marshal.c
@@ -873,7 +873,7 @@ r_bytes0(len, arg)
if (len == 0) return rb_str_new(0, 0);
if (TYPE(arg->src) == T_STRING) {
- if (RSTRING(arg->src)->len >= arg->offset + len) {
+ if (RSTRING(arg->src)->len - arg->offset >= len) {
str = rb_str_new(RSTRING(arg->src)->ptr+arg->offset, len);
arg->offset += len;
}