aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/array.c b/array.c
index 646ea16526..2d5b5ace39 100644
--- a/array.c
+++ b/array.c
@@ -2141,10 +2141,12 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
if (beg < 0) beg = 0;
}
len = NIL_P(arg2) ? RARRAY_LEN(ary) - beg : NUM2LONG(arg2);
- if (len < 0) rb_raise(rb_eIndexError, "negative length (%ld)", len);
break;
}
rb_ary_modify(ary);
+ if (len < 0) {
+ return ary;
+ }
if (beg >= ARY_MAX_SIZE || len > ARY_MAX_SIZE - beg) {
rb_raise(rb_eArgError, "argument too big");
}