summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/enum.c b/enum.c
index 978f850400..720fc09e41 100644
--- a/enum.c
+++ b/enum.c
@@ -654,6 +654,9 @@ enum_first(int argc, VALUE *argv, VALUE obj)
rb_scan_args(argc, argv, "01", &n);
len = NUM2LONG(n);
if (len == 0) return rb_ary_new2(0);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative length");
+ }
ary[0] = len;
ary[1] = rb_ary_new2(len);
}