зеркало из https://github.com/github/ruby.git
* 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:
Родитель
dfd3d1fb29
Коммит
3770ac98ff
|
@ -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
|
||||
|
|
8
array.c
8
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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче