mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (exec_recursive): prevent temporary objects from GC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
43055ad266
commit
c4cc4d31e6
2 changed files with 9 additions and 6 deletions
|
@ -1,4 +1,6 @@
|
|||
Sun Feb 20 16:23:52 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Sun Feb 20 16:26:45 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* thread.c (exec_recursive): prevent temporary objects from GC.
|
||||
|
||||
* prevent temporary objects from GC, and should not use
|
||||
RSTRING_PTR() for function calls since it evaluates the argument
|
||||
|
|
11
thread.c
11
thread.c
|
@ -3701,10 +3701,14 @@ exec_recursive_i(VALUE tag, struct exec_recursive_params *p)
|
|||
static VALUE
|
||||
exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer)
|
||||
{
|
||||
VALUE result = Qundef;
|
||||
struct exec_recursive_params p;
|
||||
int outermost;
|
||||
p.list = recursive_list_access();
|
||||
p.objid = rb_obj_id(obj);
|
||||
p.obj = obj;
|
||||
p.pairid = pairid;
|
||||
p.arg = arg;
|
||||
outermost = outer && !recursive_check(p.list, ID2SYM(recursive_key), 0);
|
||||
|
||||
if (recursive_check(p.list, p.objid, pairid)) {
|
||||
|
@ -3714,11 +3718,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
|
|||
return (*func)(obj, arg, TRUE);
|
||||
}
|
||||
else {
|
||||
VALUE result = Qundef;
|
||||
p.func = func;
|
||||
p.obj = obj;
|
||||
p.pairid = pairid;
|
||||
p.arg = arg;
|
||||
|
||||
if (outermost) {
|
||||
recursive_push(p.list, ID2SYM(recursive_key), 0);
|
||||
|
@ -3731,8 +3731,9 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
|
|||
else {
|
||||
result = exec_recursive_i(0, &p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
*(volatile struct exec_recursive_params *)&p;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue