diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-08-28 18:20:41 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-08-28 22:26:14 -0700 |
commit | a600f7e6b3c2fb66bd73b5e0893bfe1a09f26db7 (patch) | |
tree | 40f9628fdb5822cec9882db4df2e62f993477a55 /pp_hot.c | |
parent | 28f52e64fb57fb6fc7c270491c57260903a3ace3 (diff) | |
download | perl-a600f7e6b3c2fb66bd73b5e0893bfe1a09f26db7.tar.gz |
Stop creating defelems for undef in foreach(@_)
This is part of ticket #119433. This particular bug is triggered by
Data::Dump’s test suite.
Commit ce0d59f changed arrays to use NULL for nonexistent elements,
instead of &PL_sv_undef (the special scalar returned by Perl’s ‘undef’
operator).
‘foreach’ was not updated to account. It was still treating
&PL_sv_undef as a nonexistent element. This was causing ‘Modifica-
tion of non-creatable array value attempted, subscript 0’, due to a
similar bug in vivify_defelem, which the next commit will fix.
(Fixing vivify_defelem without fixing foreach will make the test pass,
but for foreach to create a defelem to begin with is inefficient and
should be addressed anyway.)
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -1918,10 +1918,7 @@ PP(pp_iter) SvREFCNT_inc_simple_void_NN(sv); } } - else - sv = &PL_sv_undef; - - if (!av_is_stack && sv == &PL_sv_undef) { + else if (!av_is_stack) { SV *lv = newSV_type(SVt_PVLV); LvTYPE(lv) = 'y'; sv_magic(lv, NULL, PERL_MAGIC_defelem, NULL, 0); @@ -1930,6 +1927,8 @@ PP(pp_iter) LvTARGLEN(lv) = (STRLEN)UV_MAX; sv = lv; } + else + sv = &PL_sv_undef; oldsv = *itersvp; *itersvp = sv; |