* 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:
parent
967001d9da
commit
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>
|
Tue Jun 2 17:32:40 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* enum.c (first_i): Enumerator#first should consume only what is
|
* 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);
|
rb_scan_args(argc, argv, "01", &n);
|
||||||
len = NUM2LONG(n);
|
len = NUM2LONG(n);
|
||||||
if (len == 0) return rb_ary_new2(0);
|
if (len == 0) return rb_ary_new2(0);
|
||||||
|
if (len < 0) {
|
||||||
|
rb_raise(rb_eArgError, "negative length");
|
||||||
|
}
|
||||||
ary[0] = len;
|
ary[0] = len;
|
||||||
ary[1] = rb_ary_new2(len);
|
ary[1] = rb_ary_new2(len);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user