From 3770ac98ff18a7ebc9836550f91b81dcfc19106d Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 2 Aug 2009 11:09:12 +0000 Subject: [PATCH] * 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 --- ChangeLog | 4 ++++ array.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e4ac6b51d..239b487f1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Aug 2 20:09:07 2009 Nobuyoshi Nakada + + * array.c (rb_ary_combination, rb_ary_product): prevent from GC. + Sun Aug 2 16:53:19 2009 Yusuke Endoh * test/ruby/test_rand.rb: add tests for Random#float's rejection diff --git a/array.c b/array.c index 0edbda46cc..bf47187906 100644 --- a/array.c +++ b/array.c @@ -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; }