]> git.vpit.fr Git - perl/modules/Lexical-Types.git/commitdiff
Fix the refcount of orig_pkg when type_pkg defaults to it
authorVincent Pit <vince@profvince.com>
Fri, 6 Mar 2009 23:53:47 +0000 (00:53 +0100)
committerVincent Pit <vince@profvince.com>
Sat, 7 Mar 2009 01:12:27 +0000 (02:12 +0100)
Types.xs

index 6fa09b1c70255040abd23a15434a5789d7df564a..8895acb0b371904adb1598074aa80724210154e2 100644 (file)
--- 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();