From: Vincent Pit Date: Fri, 6 Mar 2009 23:53:47 +0000 (+0100) Subject: Fix the refcount of orig_pkg when type_pkg defaults to it X-Git-Tag: v0.04~10 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLexical-Types.git;a=commitdiff_plain;h=f04f835b21c960f5a1021bccdd8b5a400159433a Fix the refcount of orig_pkg when type_pkg defaults to it --- diff --git a/Types.xs b/Types.xs index 6fa09b1..8895acb 100644 --- a/Types.xs +++ b/Types.xs @@ -195,8 +195,8 @@ STATIC OP *lt_ck_padany(pTHX_ OP *o) { if (stash && (hint = lt_hint())) { SV *orig_pkg = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash)); SV *orig_meth = lt_default_meth; - SV *type_pkg = orig_pkg; - SV *type_meth = orig_meth; + SV *type_pkg = NULL; + SV *type_meth = NULL; SV *code = INT2PTR(SV *, SvUVX(hint)); SvREADONLY_on(orig_pkg); @@ -243,8 +243,15 @@ STATIC OP *lt_ck_padany(pTHX_ OP *o) { LEAVE; } - if (type_meth == orig_meth) + if (!type_pkg) { + type_pkg = orig_pkg; + SvREFCNT_inc(orig_pkg); + } + + if (!type_meth) { + type_meth = orig_meth; SvREFCNT_inc(orig_meth); + } lt_pp_padsv_save();