summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-08-19 11:39:20 +0100
committerDavid Mitchell <davem@iabyn.com>2016-08-19 11:44:58 +0100
commit9fb994be1361ac6bc42256ee6a710159cf050ca5 (patch)
treec4abfcbf9c9750a49ec2ecd789db2cb56556c83e /av.c
parent7c2833f3712a18fc511622f4d27d71a3ce8a3907 (diff)
downloadperl-9fb994be1361ac6bc42256ee6a710159cf050ca5.tar.gz
av_fetch(): remove check for freed SV
Currently av_fetch() has this extra test: if (AvREIFY(av) && SvIS_FREED(AvARRAY(av)[key])) { /* eg. @_ could have freed elts */ AvARRAY(av)[key] = NULL; /* 1/2 reify */ which basically says that if the array has the reify flag set (typically only @_ has this) and if the element being retrieved in it has been freed, then replace it with an undef value instead. This can be triggered with code like: sub f { $r = 0; my $var = $_[0]; } $r = do { my $x; \$x }; f($$r); which leaves $var as undef rather than causing a "panic: attempt to copy freed scalar". However, code like my ($var) = @_; *won't* get handled specially, and will still trigger the panic. It was added in 1996 as a result of this thread: From: Andreas Koenig <k@anna.in-berlin.de> Subject: SEGV with $_[0] and circular references Message-Id: <199608131528.RAA25965@anna.in-berlin.de> That was in the context of getting a SEGV - whereas now we get the "panic: attempt to copy freed scalar" instead. It was agreed in this thread that it could be removed: http://nntp.perl.org/group/perl.perl5.porters/239082
Diffstat (limited to 'av.c')
-rw-r--r--av.c5
1 files changed, 0 insertions, 5 deletions
diff --git a/av.c b/av.c
index 8f8cda5c57..21828a9254 100644
--- a/av.c
+++ b/av.c
@@ -288,11 +288,6 @@ Perl_av_fetch(pTHX_ AV *av, SSize_t key, I32 lval)
return lval ? av_store(av,key,newSV(0)) : NULL;
}
- if (UNLIKELY(AvREIFY(av) && SvIS_FREED(AvARRAY(av)[key]))) {
- /* eg. @_ could have freed elts */
- AvARRAY(av)[key] = NULL; /* 1/2 reify */
- goto emptyness;
- }
return &AvARRAY(av)[key];
}