summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-03 00:06:40 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-03 00:06:40 +0000
commitcab726cface40ef953c748c2aa77596757ca14d4 (patch)
tree21cc65c6da20749e07d1d559cd31552f8b522686 /enum.c
parent967001d9da6a2f26736e092dba924748fa80d099 (diff)
* enum.c (enum_first): should check negative length.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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);
}