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 | 4c757a94b238100a0a08412c3068750e88541756 (patch) | |
tree | 67c21dd218bfa05fbf8b651bfbc616c5a002c37c /class.c | |
parent | fcdf6e2564990fb4fda9de685e369435790ef6d0 (diff) | |
download | ruby-4c757a94b238100a0a08412c3068750e88541756.tar.gz ruby-4c757a94b238100a0a08412c3068750e88541756.tar.xz ruby-4c757a94b238100a0a08412c3068750e88541756.zip |
* class.c (rb_mod_init_copy): fix memory leak of Class#dup.
[ruby-dev:39687]
git-svn-id: http://svn.ruby-lang.org/repos/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, |