On 02/01/2014 02:09 PM, Bugs in version via RT wrote:
Show quoted text> -------------------------------------------------------------------------
> There is also a leak in Perl_new_version since if UPG_VERSION croaks, SV "rv" is leaked. Either a early sv_2mortal and at the very end, after UPG_VERSION (and it is guarenteed we can't croak), a SvREFCNT_inc_optimized is required. Or replace the sv_2mortal with SAVEFREESV.
>
I think this is sufficient:
--- a/vutil/vutil.c Sat Feb 01 13:47:17 2014 -0500
+++ b/vutil/vutil.c Sat Feb 01 14:10:53 2014 -0500
@@ -558,6 +558,8 @@
#endif
PERL_ARGS_ASSERT_UPG_VERSION;
+ sv_2mortal(ver); /* in case we croak before we return */
+
if (SvNOK(ver)
#if PERL_VERSION_LT(5,17,2)
|| (SvTYPE(ver) == SVt_PVMG && !SvPOK(ver) && SvNOKp(ver))
@@ -674,6 +676,8 @@
#if PERL_VERSION_LT(5,19,8) && defined(USE_ITHREADS)
LEAVE;
#endif
+
+ SvREFCNT_inc_optimized(ver);
return ver;
}
That schedules ver (which is rv from new_version) to be freed at the end
of the scope, unless we are just about to return, where we inc it back
to life again.
John