summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-06-23 09:44:45 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-06-23 10:23:45 -0700
commit4bee03f8e20d4e5257132fdea9f9fac4206c79f8 (patch)
tree622f6406d363cda9f90958b6698c272ffac4c41a /pp_ctl.c
parent0accd0eeebd92a8877c7f7ecc13c7cb3ec364faa (diff)
downloadperl-4bee03f8e20d4e5257132fdea9f9fac4206c79f8.tar.gz
Fix explicit return of pad var in list lv context
This is something that commit e08be60 missed, though it never worked properly, even in 5.14, as explicit return from lvalue subs used to copy return values. As the commit message for e08be60 states, returning a scalar itself from an lvalue sub does not work if it is a pad variable with a refer- ence count of 1, because the sub-popping code clears it on exit. The one code path that did not account for this was list lvalue con- text (real lvalue context, not just potentially lvalue). The only observable effect this has is that assigning to a magic pad variable returned from a subroutine in list context will not trigger set-magic. This commit fixes it and also adds tests for returned magic pad vars in all combinations of list/scalar lvalue/ref context.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 98f2e5d2a6..36ba24a664 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2334,7 +2334,10 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, I32 gimme,
SvREADONLY(TOPs) ? "readonly value" : "temporary");
}
else
- *++newsp = *MARK;
+ *++newsp =
+ SvTEMP(*MARK)
+ ? *MARK
+ : sv_2mortal(SvREFCNT_inc_simple_NN(*MARK));
}
}
PL_stack_sp = newsp;