summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/array.c b/array.c
index a53554b..6fdcf66 100644
--- a/array.c
+++ b/array.c
@@ -306,9 +306,6 @@ ary_subseq(ary, beg, len)
beg = RARRAY(ary)->len + beg;
if (beg < 0) beg = 0;
}
- if (beg >= RARRAY(ary)->len) {
- IndexError("out of range %d", beg);
- }
if (len < 0) {
IndexError("negative length %d", RARRAY(ary)->len);
}
@@ -318,6 +315,9 @@ ary_subseq(ary, beg, len)
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}
+ if (len < 0) {
+ len = 0;
+ }
ary2 = ary_new2(len);
MEMCPY(RARRAY(ary2)->ptr, RARRAY(ary)->ptr+beg, VALUE, len);