summaryrefslogtreecommitdiffstats
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
commitbd08e4d4936665364998ed900c807b4fac28ba11 (patch)
tree21cc65c6da20749e07d1d559cd31552f8b522686 /enum.c
parent9bbc34ac6c68ed233620b2d9f9514cce1d8a4892 (diff)
downloadruby-bd08e4d4936665364998ed900c807b4fac28ba11.tar.gz
ruby-bd08e4d4936665364998ed900c807b4fac28ba11.tar.xz
ruby-bd08e4d4936665364998ed900c807b4fac28ba11.zip
* enum.c (enum_first): should check negative length.
git-svn-id: http://svn.ruby-lang.org/repos/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 978f85040..720fc09e4 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);
}