1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_combination, rb_ary_product): prevent from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-08-02 11:09:12 +00:00
parent dfd3d1fb29
commit 3770ac98ff
2 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,7 @@
Sun Aug 2 20:09:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (rb_ary_combination, rb_ary_product): prevent from GC.
Sun Aug 2 16:53:19 2009 Yusuke Endoh <mame@tsg.ne.jp>
* test/ruby/test_rand.rb: add tests for Random#float's rejection

View file

@ -3748,8 +3748,8 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary)
for (i = 0; i < n; i++) used[i] = 0; /* initialize array */
permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */
RB_GC_GUARD(t0);
RB_GC_GUARD(t1);
ary_discard(t0);
ary_discard(t1);
RBASIC(ary0)->klass = rb_cArray;
}
return ary;
@ -3839,6 +3839,8 @@ rb_ary_combination(VALUE ary, VALUE num)
stack[lev--]++;
} while (lev && (stack[lev+1]+n == len+lev+1));
}
ary_discard(t0);
ary_discard(cc);
}
return ary;
}
@ -3916,6 +3918,8 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
counters[m]++;
}
}
ary_discard(t0);
ary_discard(t1);
return result;
}