summaryrefslogtreecommitdiffstats
path: root/class.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-14 12:56:16 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-14 12:56:16 +0000
commit4c757a94b238100a0a08412c3068750e88541756 (patch)
tree67c21dd218bfa05fbf8b651bfbc616c5a002c37c /class.c
parentfcdf6e2564990fb4fda9de685e369435790ef6d0 (diff)
downloadruby-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.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/class.c b/class.c
index a97494b8d..056e1715b 100644
--- a/class.c
+++ b/class.c
@@ -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,