summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/array.c b/array.c
index 128f7de..766d304 100644
--- a/array.c
+++ b/array.c
@@ -355,9 +355,12 @@ rb_ary_subary(ary, beg, len)
{
VALUE ary2;
- if (len < 0) return Qnil;
if (beg > RARRAY(ary)->len) return Qnil;
- if (beg < 0) return Qnil;
+ if (beg < 0) {
+ len += beg;
+ beg = 0;
+ }
+ if (len < 0) return Qnil;
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}