From: gfx Date: Fri, 21 Aug 2009 08:38:50 +0000 (+0900) Subject: Fix a memory leak X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=592964be46bb5562cf244353ea42fc1734239701;p=gitmo%2FClass-MOP.git Fix a memory leak --- diff --git a/xs/MethodAccessor.xs b/xs/MethodAccessor.xs index d55cd9f..18e4c3d 100644 --- a/xs/MethodAccessor.xs +++ b/xs/MethodAccessor.xs @@ -19,6 +19,11 @@ mop_install_accessor(pTHX_ const char* const fq_name, const char* const key, I32 vtbl = mop_get_default_instance_vtbl(aTHX); } + if(!fq_name){ + /* generated_xsub need sv_2mortal */ + sv_2mortal((SV*)xsub); + } + mg = sv_magicext((SV*)xsub, (SV*)meta, PERL_MAGIC_ext, &mop_accessor_vtbl, (char*)vtbl, 0); SvREFCNT_dec(meta); /* sv_magicext() increases refcnt in mg_obj */