summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'range.c')
-rw-r--r--range.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/range.c b/range.c
index 74bbdcd..7f0e0c5 100644
--- a/range.c
+++ b/range.c
@@ -191,7 +191,11 @@ rb_range_beg_len(range, begp, lenp, len, err)
beg += len;
if (beg < 0) goto out_of_range;
}
- if (err == 2 && beg > len) goto out_of_range;
+ if (err == 2) {
+ if (beg > len) goto out_of_range;
+ if (end > len || (!EXCL(range) && end == len))
+ goto out_of_range;
+ }
if (end < 0) {
end += len;
if (end < 0) {