[前][次][番号順一覧][スレッド一覧]

ruby-changes:30626

From: nobu <ko1@a...>
Date: Tue, 27 Aug 2013 16:51:32 +0900 (JST)
Subject: [ruby-changes:30626] nobu:r42705 (trunk): enumerator.c: check arg size

nobu	2013-08-27 16:51:27 +0900 (Tue, 27 Aug 2013)

  New Revision: 42705

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42705

  Log:
    enumerator.c: check arg size
    
    * enumerator.c (enumerator_each): ensure argument array size is int.

  Modified files:
    trunk/ChangeLog
    trunk/enumerator.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42704)
+++ ChangeLog	(revision 42705)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Aug 27 16:51:21 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* enumerator.c (enumerator_each): ensure argument array size is int.
+
 Tue Aug 27 16:46:05 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* array.c (rb_ary_index, rb_ary_rindex): use optimized equality to
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 42704)
+++ enumerator.c	(revision 42705)
@@ -447,6 +447,9 @@ enumerator_each(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/enumerator.c#L447
 	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) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1012
     }
     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 {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]