mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enumerator.c (lazy_cycle): check argument number overflow before
creating temporary array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a258d6f415
commit
fbdce66908
2 changed files with 14 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Mar 15 15:19:38 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enumerator.c (lazy_cycle): check argument number overflow before
|
||||
creating temporary array.
|
||||
|
||||
Thu Mar 15 15:04:54 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* util.c (ruby_strtod): no need to check same digit for hexdigit
|
||||
|
|
17
enumerator.c
17
enumerator.c
|
@ -106,7 +106,7 @@ VALUE rb_cEnumerator;
|
|||
VALUE rb_cLazy;
|
||||
static ID id_rewind, id_each, id_new, id_initialize, id_yield, id_call;
|
||||
static ID id_eqq, id_next, id_result, id_lazy;
|
||||
static VALUE sym_each;
|
||||
static VALUE sym_each, sym_cycle;
|
||||
|
||||
VALUE rb_eStopIteration;
|
||||
|
||||
|
@ -1526,17 +1526,17 @@ static VALUE
|
|||
lazy_cycle(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE args;
|
||||
int i;
|
||||
int len = rb_long2int((long)argc + 2);
|
||||
|
||||
args = rb_ary_new2(argc + 1);
|
||||
args = rb_ary_tmp_new(len);
|
||||
rb_ary_push(args, obj);
|
||||
rb_ary_push(args, ID2SYM(rb_intern("cycle")));
|
||||
for (i = 0; i < argc; i++) {
|
||||
rb_ary_push(args, argv[i]);
|
||||
rb_ary_push(args, sym_cycle);
|
||||
if (argc > 0) {
|
||||
rb_ary_cat(args, argv, argc);
|
||||
}
|
||||
return rb_block_call(rb_cLazy, id_new, RARRAY_LEN(args), RARRAY_PTR(args),
|
||||
return rb_block_call(rb_cLazy, id_new, len, RARRAY_PTR(args),
|
||||
rb_block_given_p() ? lazy_map_func : lazy_cycle_func,
|
||||
0);
|
||||
args /* prevent from GC */);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -1680,6 +1680,7 @@ Init_Enumerator(void)
|
|||
id_lazy = rb_intern("lazy");
|
||||
id_eqq = rb_intern("===");
|
||||
sym_each = ID2SYM(id_each);
|
||||
sym_cycle = ID2SYM(rb_intern("cycle"));
|
||||
|
||||
InitVM(Enumerator);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue