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=616d909b2ad3afd1e5a3f4cab46b8f47296ab240;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 */