perl/perl-5.14.2-Stop-V-from-leaking.patch
2012-02-06 16:05:19 +01:00

55 lines
1.4 KiB
Diff

From 8ee4f541d4632a3615e70e177e004c5db970c8cd Mon Sep 17 00:00:00 2001
From: Father Chrysostomos <sprout@cpan.org>
Date: Fri, 3 Feb 2012 21:55:31 -0800
Subject: [PATCH] Stop !$^V from leaking
by mortalising the temporary SVs.
Petr Pisar: Back-port for 5.14.2.
---
t/op/svleak.t | 4 +++-
universal.c | 8 +++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/t/op/svleak.t b/t/op/svleak.t
index 5eb090c..0f4348e 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -13,7 +13,7 @@ BEGIN {
or skip_all("XS::APItest not available");
}
-plan tests => 19;
+plan tests => 20;
# run some code N times. If the number of SVs at the end of loop N is
# greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -141,3 +141,5 @@ leak(2, 0,
},
"rcatline leak"
);
+
+leak(2,0,sub { !$^V }, '[perl #109762] version object in boolean context');
diff --git a/universal.c b/universal.c
index 092ee80..9615d59 100644
--- a/universal.c
+++ b/universal.c
@@ -544,7 +544,13 @@ XS(XS_version_boolean)
SP -= items;
if (sv_derived_from(ST(0), "version") && SvROK(ST(0))) {
SV * const lobj = SvRV(ST(0));
- SV * const rs = newSViv( vcmp(lobj,new_version(newSVpvs("0"))) );
+ SV * const rs =
+ newSViv( vcmp(lobj,
+ sv_2mortal(new_version(
+ sv_2mortal(newSVpvs("0"))
+ ))
+ )
+ );
mPUSHs(rs);
PUTBACK;
return;
--
1.7.7.6