summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-23 09:58:45 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-23 09:58:45 +0000
commitd848edb1d5ee68896950e9b5fe3e57badfdfb680 (patch)
tree386790e0b609ad8c4b14ca8a6c9d40e3104bf040 /class.c
parentdedbe778faa8c7a5de321412e30588ff162fb34a (diff)
merge revision(s) 45874: [Backport #9813]
* class.c (rb_mod_init_copy): always clear instance variable, constant and method tables first, regardless the source tables. [ruby-dev:48182] [Bug #9813] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/class.c b/class.c
index 25ac2eb6c0..384037b2b7 100644
--- a/class.c
+++ b/class.c
@@ -205,12 +205,21 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
}
RCLASS_SUPER(clone) = RCLASS_SUPER(orig);
RCLASS_EXT(clone)->allocator = RCLASS_EXT(orig)->allocator;
+ if (RCLASS_IV_TBL(clone)) {
+ st_free_table(RCLASS_IV_TBL(clone));
+ RCLASS_IV_TBL(clone) = 0;
+ }
+ if (RCLASS_CONST_TBL(clone)) {
+ rb_free_const_table(RCLASS_CONST_TBL(clone));
+ RCLASS_CONST_TBL(clone) = 0;
+ }
+ if (RCLASS_M_TBL(clone)) {
+ rb_free_m_table(RCLASS_M_TBL(clone));
+ RCLASS_M_TBL(clone) = 0;
+ }
if (RCLASS_IV_TBL(orig)) {
st_data_t id;
- if (RCLASS_IV_TBL(clone)) {
- st_free_table(RCLASS_IV_TBL(clone));
- }
RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig));
CONST_ID(id, "__tmp_classpath__");
st_delete(RCLASS_IV_TBL(clone), &id, 0);
@@ -220,16 +229,11 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
st_delete(RCLASS_IV_TBL(clone), &id, 0);
}
if (RCLASS_CONST_TBL(orig)) {
- if (RCLASS_CONST_TBL(clone)) {
- rb_free_const_table(RCLASS_CONST_TBL(clone));
- }
+
RCLASS_CONST_TBL(clone) = st_init_numtable();
st_foreach(RCLASS_CONST_TBL(orig), clone_const_i, (st_data_t)RCLASS_CONST_TBL(clone));
}
if (RCLASS_M_TBL(orig)) {
- if (RCLASS_M_TBL(clone)) {
- rb_free_m_table(RCLASS_M_TBL(clone));
- }
RCLASS_M_TBL(clone) = st_init_numtable();
st_foreach(RCLASS_M_TBL(orig), clone_method_i, (st_data_t)clone);
}