зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
967001d9da
Коммит
cab726cfac
|
@ -1,3 +1,7 @@
|
|||
Wed Jun 3 09:03:23 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* enum.c (enum_first): should check negative length.
|
||||
|
||||
Tue Jun 2 17:32:40 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* enum.c (first_i): Enumerator#first should consume only what is
|
||||
|
|
3
enum.c
3
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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче