From d1b77f5eee442d6104b92e7edf272c8bdac6be44 Mon Sep 17 00:00:00 2001 From: wanabe Date: Sat, 21 Aug 2010 10:00:55 +0000 Subject: [PATCH] * vm.c (vm_define_method): copy iseq to avoid overwriting iseq->klass. #2502, #3136. see #2420. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ vm.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 84f9093a14..5f12db81a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Aug 21 18:54:56 2010 wanabe + + * vm.c (vm_define_method): copy iseq to avoid overwriting iseq->klass. + #2502, #3136. see #2420. + Sat Aug 21 17:36:42 2010 Tanaka Akira * ext/pathname/pathname.c (path_split): Pathname#split translated from diff --git a/vm.c b/vm.c index e62c9a4b7b..eb49722fcd 100644 --- a/vm.c +++ b/vm.c @@ -1844,6 +1844,11 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, rb_iseq_t *miseq; GetISeqPtr(iseqval, miseq); + if (miseq->klass) { + iseqval = rb_iseq_clone(iseqval, 0); + GetISeqPtr(iseqval, miseq); + } + if (NIL_P(klass)) { rb_raise(rb_eTypeError, "no class/module to add method"); }