summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-10-02 22:38:27 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-11 00:10:15 -0700
commitd39c26a657753cddffc8cb3dbd2aaa929b2c78fe (patch)
treee3061d7ad6cb247565e7ce16a74db2eddc5a07e7 /mg.c
parent5a36b2c090849e18b86c1759887c5bcebd598113 (diff)
downloadperl-d39c26a657753cddffc8cb3dbd2aaa929b2c78fe.tar.gz
foreach \$var
Some passing tests are still marked to-do. We need more tests still.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mg.c b/mg.c
index 2b310e3272..bf98374be0 100644
--- a/mg.c
+++ b/mg.c
@@ -2507,7 +2507,14 @@ Perl_magic_setlvref(pTHX_ SV *sv, MAGIC *mg)
hv_store_ent((HV *)mg->mg_obj, (SV *)mg->mg_ptr,
SvREFCNT_inc_simple_NN(SvRV(sv)), 0);
}
- sv_unmagic(sv, PERL_MAGIC_lvref);
+ if (mg->mg_flags & MGf_PERSIST)
+ NOOP; /* This sv is in use as an iterator var and will be reused,
+ so we must leave the magic. */
+ else
+ /* This sv could be returned by the assignment op, so clear the
+ magic, as lvrefs are an implementation detail that must not be
+ leaked to the user. */
+ sv_unmagic(sv, PERL_MAGIC_lvref);
return 0;
}