mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
enumerator.c: check arg size
* enumerator.c (enumerator_each): ensure argument array size is int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f25daa2541
commit
a5f18c1f9d
2 changed files with 8 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
Tue Aug 27 16:51:21 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enumerator.c (enumerator_each): ensure argument array size is int.
|
||||
|
||||
Tue Aug 27 16:46:05 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_index, rb_ary_rindex): use optimized equality to
|
||||
|
|
|
@ -447,6 +447,9 @@ enumerator_each(int argc, VALUE *argv, VALUE obj)
|
|||
struct enumerator *e = enumerator_ptr(obj = rb_obj_dup(obj));
|
||||
VALUE args = e->args;
|
||||
if (args) {
|
||||
#if SIZEOF_INT < SIZEOF_LONG
|
||||
rb_long2int(RARRAY_LEN(args) + argc);
|
||||
#endif
|
||||
args = rb_ary_dup(args);
|
||||
rb_ary_cat(args, argv, argc);
|
||||
}
|
||||
|
@ -1009,7 +1012,7 @@ enumerator_size(VALUE obj)
|
|||
}
|
||||
if (rb_respond_to(e->size, id_call)) {
|
||||
if (e->args) {
|
||||
int argc = RARRAY_LENINT(e->args);
|
||||
int argc = (int)RARRAY_LEN(e->args);
|
||||
VALUE *argv = RARRAY_PTR(e->args);
|
||||
return rb_funcall2(e->size, id_call, argc, argv);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue