summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sv.c4
-rw-r--r--t/op/svleak.t2
2 files changed, 3 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index a2d29bad1a..6f7584778a 100644
--- a/sv.c
+++ b/sv.c
@@ -3739,7 +3739,7 @@ S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype)
static void
S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr)
{
- SV * const sref = SvREFCNT_inc(SvRV(sstr));
+ SV * const sref = SvRV(sstr);
SV *dref = NULL;
const int intro = GvINTRO(dstr);
SV **location;
@@ -3825,7 +3825,7 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr)
GvASSUMECV_on(dstr);
if(GvSTASH(dstr)) mro_method_changed_in(GvSTASH(dstr)); /* sub foo { 1 } sub bar { 2 } *bar = \&foo */
}
- *location = sref;
+ *location = SvREFCNT_inc_simple_NN(sref);
if (import_flag && !(GvFLAGS(dstr) & import_flag)
&& CopSTASH_ne(PL_curcop, GvSTASH(dstr))) {
GvFLAGS(dstr) |= import_flag;
diff --git a/t/op/svleak.t b/t/op/svleak.t
index e3f6be4e6b..a3c14b80b6 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -87,11 +87,11 @@ eleak(2, 0, "no warnings; use feature ':all'; $all
my sub foo{} sub foo:lvalue{}",
'fatal mysub redef warning');
eleak(2, 0, "$all sub foo{} sub foo{}", 'fatal sub redef warning');
-$::TODO = 'still leaks';
eleak(2, 0, "$all *x=sub {}",
'fatal sub redef warning with sub-to-glob assignment');
eleak(2, 0, "$all *x=sub() {1}",
'fatal const sub redef warning with sub-to-glob assignment');
+$::TODO = 'still leaks';
eleak(2, 0, "$all XS::APItest::newCONSTSUB(\\%main::=>name=>0=>1)",
'newXS sub redefinition with fatal warnings');
eleak(2, 0, "$f 'misc'; my\$a,my\$a", 'double my with fatal warnings');