Stop leaking temporary version objects from XS
authorgfx <gfuji@cpan.org>
Wed, 5 May 2010 10:54:11 +0000 (06:54 -0400)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 30 Aug 2011 03:30:26 +0000 (20:30 -0700)
(cherry picked from commit e3a22e3fde4a0485bb3fee606a63025eb3214eb9)

universal.c

index 006baa2..2cafbff 100644 (file)
@@ -510,20 +510,20 @@ XS(XS_UNIVERSAL_VERSION)
            if ( hv_exists(MUTABLE_HV(SvRV(req)), "qv", 2 ) ) {
                Perl_croak(aTHX_ "%s version %"SVf" required--"
                       "this is only version %"SVf"", HvNAME_get(pkg),
-                      SVfARG(vnormal(req)),
-                      SVfARG(vnormal(sv)));
+                      SVfARG(sv_2mortal(vnormal(req))),
+                      SVfARG(sv_2mortal(vnormal(sv))));
            } else {
                Perl_croak(aTHX_ "%s version %"SVf" required--"
                       "this is only version %"SVf"", HvNAME_get(pkg),
-                      SVfARG(vstringify(req)),
-                      SVfARG(vstringify(sv)));
+                      SVfARG(sv_2mortal(vstringify(req))),
+                      SVfARG(sv_2mortal(vstringify(sv))));
            }
        }
 
     }
 
     if ( SvOK(sv) && sv_derived_from(sv, "version") ) {
-       ST(0) = vstringify(sv);
+       ST(0) = sv_2mortal(vstringify(sv));
     } else {
        ST(0) = sv;
     }
@@ -659,7 +659,8 @@ XS(XS_version_vcmp)
 
               if ( ! sv_derived_from(robj, "version") )
               {
-                   robj = new_version(SvOK(robj) ? robj : newSVpvs("0"));
+                   robj = new_version(SvOK(robj) ? robj : newSVpvs_flags("0", SVs_TEMP));
+                   sv_2mortal(robj);
               }
               rvs = SvRV(robj);