From 2047c47d638b8fb5c1d756a202962ea872153997 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 31 Jul 2003 06:30:35 +0000 Subject: * array.c (rb_ary_collect): must get length of array for each iteration. reported on [ruby-talk:77500], and fixed by K.Sasada on [ruby-talk:77504] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index 9404e6ae5f..e51b8b54f4 100644 --- a/array.c +++ b/array.c @@ -1190,16 +1190,15 @@ static VALUE rb_ary_collect(ary) VALUE ary; { - long len, i; + long i; VALUE collect; if (!rb_block_given_p()) { return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr); } - len = RARRAY(ary)->len; - collect = rb_ary_new2(len); - for (i=0; ilen); + for (i = 0; i < RARRAY(ary)->len; i++) { rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr[i])); } return collect; -- cgit v1.2.1