* enum.c (enum_first): Perform negative length check before

attempting to make an array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2009-06-27 20:10:45 +00:00
parent 3f594ce1d8
commit c5a88815d9
2 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,8 @@
Sun Jun 28 05:11:03 2009 Akinori MUSHA <knu@iDaemons.org>
* enum.c (enum_first): Perform negative length check before
attempting to make an array.
Sat Jun 27 13:47:19 2009 Kouhei Sutou <kou@cozmixng.org>
* NEWS, lib/rss/maker/base.rb, test/rss/test_maker_2.0.rb: add

3
enum.c
View File

@ -704,6 +704,9 @@ enum_first(argc, argv, 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] = INT2NUM(len);
ary[1] = rb_ary_new2(len);
}