diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-14 12:56:16 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-14 12:56:16 +0000 |
commit | 4a761c320932ee03b5386d68411737f7fa7bd3e2 (patch) | |
tree | 67c21dd218bfa05fbf8b651bfbc616c5a002c37c /class.c | |
parent | 85ca612b135c1ed47cc01be48e21f20fc7bd9ffc (diff) | |
download | ruby-4a761c320932ee03b5386d68411737f7fa7bd3e2.tar.gz |
* class.c (rb_mod_init_copy): fix memory leak of Class#dup.
[ruby-dev:39687]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -151,6 +151,9 @@ rb_mod_init_copy(VALUE clone, VALUE orig) if (RCLASS_IV_TBL(orig)) { ID 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, "__classpath__"); st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0); @@ -159,6 +162,11 @@ rb_mod_init_copy(VALUE clone, VALUE orig) } if (RCLASS_M_TBL(orig)) { struct clone_method_data data; + + if (RCLASS_M_TBL(clone)) { + extern void rb_free_m_table(st_table *tbl); + rb_free_m_table(RCLASS_M_TBL(clone)); + } data.tbl = RCLASS_M_TBL(clone) = st_init_numtable(); data.klass = clone; st_foreach(RCLASS_M_TBL(orig), clone_method, |