Stop leaking temporary version objects from XS
authorgfx <gfuji@cpan.org>
Wed, 5 May 2010 10:54:11 +0000 (06:54 -0400)
committerJesse Vincent <jesse@bestpractical.com>
Tue, 29 Jun 2010 02:30:06 +0000 (22:30 -0400)
universal.c

index 2f73dd0..07a0aa6 100644 (file)
@@ -392,20 +392,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;
     }
@@ -541,7 +541,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);