summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-01-02 10:09:31 -0700
committerKarl Williamson <khw@cpan.org>2020-01-02 10:16:24 -0700
commit811f8a246ee7da5274c3229345222e9fe5febbe0 (patch)
treeb55f671469eb4865f27ac982c9d3e11cc6cbb1d5 /av.c
parentb790ed71bdb9ac73a66f9dc2639f19950391ed45 (diff)
downloadperl-811f8a246ee7da5274c3229345222e9fe5febbe0.tar.gz
Revert "Add some defensive coding to av_store()"
This reverts commit bc62bf8519f9005df2fb29dbd3d330202b258b6b. As Dave Mitchell said in <Perl/perl5/issues/17265/570253376@github.com> "The docs for av_store() say that the caller is responsible for first incrementing the ref count of the new SV before passing it to av_store(). In the normal case of the two elements being different, av_store() will decrement the old SV before storing the new one, and everything is good. When the two elements are the same SV, av_store() *still* needs to decrement the ref count, to undo the increment the caller just did." This should resolve GH #17265
Diffstat (limited to 'av.c')
-rw-r--r--av.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/av.c b/av.c
index f10f1247f4..918844c376 100644
--- a/av.c
+++ b/av.c
@@ -356,8 +356,8 @@ Perl_av_store(pTHX_ AV *av, SSize_t key, SV *val)
}
AvFILLp(av) = key;
}
- else if (AvREAL(av) && LIKELY(ary[key] != val))
- SvREFCNT_dec(ary[key]);
+ else if (AvREAL(av))
+ SvREFCNT_dec(ary[key]);
ary[key] = val;
if (SvSMAGICAL(av)) {
const MAGIC *mg = SvMAGIC(av);