summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-05-27 17:45:50 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-05-27 17:46:08 -0700
commit4587c5322c964beac01a38188957ca11026dc766 (patch)
tree8b4a16d53c35dd055d52433514ba82f9e52ec951 /pp_hot.c
parent717a97bab95e1c5b372d6ecc681398092afcffd6 (diff)
downloadperl-4587c5322c964beac01a38188957ca11026dc766.tar.gz
[perl #117947] Verify lvalueness of XSUBs at run time
If the sub is not visible at compile time, the op tree is flagged such that pp_entersub will know whether to check the lvalueness of the called sub. That check has been in pp_entersub since da1dff9483c. When I moved it to pp_entersub in that commit, I only added it to the pure-Perl branch, not to the XS branch, allowing all XSUBs to be treated as lvalues if they are not visible at compile time.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/pp_hot.c b/pp_hot.c
index dd9e5f15be..157c469122 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2847,6 +2847,12 @@ try_autoload:
PUTBACK;
+ if (((PL_op->op_private
+ & PUSHSUB_GET_LVALUE_MASK(Perl_is_lvalue_sub)
+ ) & OPpENTERSUB_LVAL_MASK) == OPpLVAL_INTRO &&
+ !CvLVALUE(cv))
+ DIE(aTHX_ "Can't modify non-lvalue subroutine call");
+
if (!hasargs) {
/* Need to copy @_ to stack. Alternative may be to
* switch stack to @_, and copy return values