diff --git a/ChangeLog b/ChangeLog index 041795ae13..fd85383d62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jan 26 22:57:30 2011 CHIKANAGA Tomoyuki + + * class.c (clone_method): add GC guard to prevent intermediate + variable from GC. [Bug #4321] [ruby-dev:43107] + Wed Jan 26 22:45:16 2011 Tanaka Akira * template/id.h.tmpl: parenthesize macro arguments. diff --git a/class.c b/class.c index 76f4ef8622..0d7623350f 100644 --- a/class.c +++ b/class.c @@ -129,11 +129,13 @@ VALUE rb_iseq_clone(VALUE iseqval, VALUE newcbase); static int clone_method(ID mid, const rb_method_entry_t *me, struct clone_method_data *data) { + VALUE newiseqval; if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) { - VALUE newiseqval = rb_iseq_clone(me->def->body.iseq->self, data->klass); rb_iseq_t *iseq; + newiseqval = rb_iseq_clone(me->def->body.iseq->self, data->klass); GetISeqPtr(newiseqval, iseq); rb_add_method(data->klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag); + RB_GC_GUARD(newiseqval); } else { rb_method_entry_set(data->klass, mid, me, me->flag);