diff options
author | David Mitchell <davem@iabyn.com> | 2015-10-17 13:24:30 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-02-03 09:18:30 +0000 |
commit | 9d1ee8e070881fd97d9311709893d0980afe43c9 (patch) | |
tree | 0378add26876c47dba16dba4d8f82456fcad5fac /t | |
parent | 0925dc7fc4dca2e6b5f629d00032568d5bcc2c5b (diff) | |
download | perl-9d1ee8e070881fd97d9311709893d0980afe43c9.tar.gz |
simplify two conditions in pp_iter:
- if (UNLIKELY(SvMAGICAL(av) || AvREIFY(av))) {
+ if (UNLIKELY(SvRMAGICAL(av))) {
This condition is deciding whether to call av_fetch or cheat and do
sv = AvARRAY(av)[ix].
The magic test is too broad: av_fetch() only handles the specially on
RMG, not all magic.
The AvREIFY condition was originally added by 64138690 in 2001. It was
an attempt to paper over the cracks if function args are deleted, then
iterate over @_, which now contains freed elements. Since pp_iter now
includes a 'freed sv' check itself, there's no need to call into av_fetch
which has a similar check.
This makes a slight functional change - previously if @_ contained a freed
element, av_fetch would silently return NULL; now instead, pp_iter
croaks with "Use of freed value in iteration", the same as it does with
all other cases involving freed elements being iterated over.
Diffstat (limited to 't')
-rw-r--r-- | t/run/fresh_perl.t | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/t/run/fresh_perl.t b/t/run/fresh_perl.t index f148317bf0..4b5f7766d8 100644 --- a/t/run/fresh_perl.t +++ b/t/run/fresh_perl.t @@ -624,12 +624,13 @@ my @h = 1 .. 10; bad(@h); sub bad { undef @h; - print "O"; + warn "O\n"; print for @_; - print "K"; + warn "K\n"; } EXPECT -OK +O +Use of freed value in iteration at - line 7. ######## # Bug 20010506.041 "abcd\x{1234}" =~ /(a)(b[c])(d+)?/i and print "ok\n"; |