diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-06-20 21:44:00 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-06-22 23:16:39 -0700 |
commit | 60041a0991995a4c82b6531822e284e1cc1c8a07 (patch) | |
tree | 2c222e797cc5145a4d48f4ce3fb70108a2cbdc43 /op.h | |
parent | 48c357fd49c074d84fc228fa5b89b851bd74d637 (diff) | |
download | perl-60041a0991995a4c82b6531822e284e1cc1c8a07.tar.gz |
Stop split from mangling constants
At compile time, if split occurs on the right-hand side of an assign-
ment to a list of scalars, if the limit argument is a constant con-
taining the number 0 then it is modified in place to hold one more
than the number of scalars.
This means ‘constants’ can change their values, if they happen to be
in the wrong place at the wrong time:
$ ./perl -Ilib -le 'use constant NULL => 0; ($a,$b,$c) = split //, $foo, NULL; print NULL'
4
I considered checking the reference count on the SV, but since XS code
could create its own const ops with weak references to the same cons-
tants elsewhere, the safest way to avoid modifying someone else’s SV
is to mark the split op in ck_split so we know the SV belongs to that
split op alone.
Also, to be on the safe side, turn off the read-only flag before modi-
fying the SV, instead of relying on the special case for compile time
in sv_force_normal.
Diffstat (limited to 'op.h')
-rw-r--r-- | op.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -324,6 +324,9 @@ Deprecated. Use C<GIMME_V> instead. /* Private for OP_(LAST|REDO|NEXT|GOTO|DUMP) */ #define OPpPV_IS_UTF8 128 /* label is in UTF8 */ +/* Private for OP_SPLIT */ +#define OPpSPLIT_IMPLIM 128 /* implicit limit */ + struct op { BASEOP }; |