diff options
author | Gerard Goossen <gerard@ggoossen.net> | 2011-08-24 14:26:51 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-24 14:26:51 -0700 |
commit | 9026059dcee814a1dd826752b902416a3eff6eb2 (patch) | |
tree | 1cb3e4b0b071f4e9f6d8d2d0b05618d382cf525b /embed.fnc | |
parent | 835c0338f857876193eb10d8e9d5a6efe142b2a9 (diff) | |
download | perl-9026059dcee814a1dd826752b902416a3eff6eb2.tar.gz |
[perl #97088] Prevent double get-magic in various cases
This patch prevents get-magic from executing twice during autovivifi-
cation when the op doing the autovivification is not directly nested
inside the dereferencing op.
This can happen in cases like this:
${ (), $a } = 1;
Previously (as of 5.13.something), the outer op was marked with the
OPpDEREFed flag, which indicated that get-magic had already been
called by the vivifying op (calling get-magic during vivification is
inevitable):
$ perl5.14.0 -MO=Concise -e '${ $a } = 1'
8 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 2 -e:1) v:{ ->3
7 <2> sassign vKS/2 ->8
3 <$> const[IV 1] s ->4
6 <1> rv2sv sKRM*/DREFed,1 ->7 <-- right here
- <@> scope sK ->6
- <0> ex-nextstate v ->4
5 <1> rv2sv sKM/DREFSV,1 ->6
4 <#> gv[*a] s ->5
-e syntax OK
But in the ${()...} example above, there is a list op in the way that
prevents the flag from being set inside the peephole optimizer. It’s
not even possible to set it correctly in all cases, as in this exam-
ple, which would need it both set and not set depending on which
branch of the ternary operator is executed:
${ $x ? delete $a[0] : $a[0] } = 1
Instead of setting the OPpDEREFed flag, we now make a non-magic copy
of the SV in vivify_ref (the first time get-magic is executed).
Diffstat (limited to 'embed.fnc')
-rw-r--r-- | embed.fnc | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1384,7 +1384,7 @@ ApdR |char* |sv_uni_display |NN SV *dsv|NN SV *ssv|STRLEN pvlim|UV flags : Used by Data::Alias EXp |void |vivify_defelem |NN SV* sv : Used in pp.c -p |void |vivify_ref |NN SV* sv|U32 to_what +pR |SV* |vivify_ref |NN SV* sv|U32 to_what : Used in pp_sys.c p |I32 |wait4pid |Pid_t pid|NN int* statusp|int flags : Used in locale.c and perl.c |