aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index 4968e86d74..43b8b4e007 100644
--- a/string.c
+++ b/string.c
@@ -5254,7 +5254,7 @@ str_byte_substr(VALUE str, long beg, long len, int empty)
beg += n;
if (beg < 0) return Qnil;
}
- if (beg + len > n)
+ if (len > n - beg)
len = n - beg;
if (len <= 0) {
if (!empty) return Qnil;