diff options
author | Mark Mielke <mark@mark.mielke.cc> | 2003-01-20 14:56:13 -0500 |
---|---|---|
committer | hv <hv@crypt.org> | 2003-02-11 00:27:56 +0000 |
commit | d91d49e893f41bf2ce59ca71dfaeeb27d6b2cfa0 (patch) | |
tree | bd7d7a427d111d93d325110392d6078670cdda1f /sv.c | |
parent | 8a2e3f14e33ebd36c920e88c0181ef8a85ec2cc8 (diff) | |
download | perl-d91d49e893f41bf2ce59ca71dfaeeb27d6b2cfa0.tar.gz |
PATCH: sv_rvweaken() deficiency (against 5.8.0)
Message-ID: <20030121005613.GA31739@mark.mielke.cc>
p4raw-id: //depot/perl@18691
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -4964,7 +4964,19 @@ S_sv_add_backref(pTHX_ SV *tsv, SV *sv) sv_magic(tsv, (SV*)av, PERL_MAGIC_backref, NULL, 0); SvREFCNT_dec(av); /* for sv_magic */ } - av_push(av,sv); + if (AvFILLp(av) >= AvMAX(av)) { + SV **svp = AvARRAY(av); + I32 i = AvFILLp(av); + while (i >= 0) { + if (svp[i] == &PL_sv_undef) { + svp[i] = sv; /* reuse the slot */ + return; + } + i--; + } + av_extend(av, AvFILLp(av)+1); + } + AvARRAY(av)[++AvFILLp(av)] = sv; /* av_push() */ } /* delete a back-reference to ourselves from the backref magic associated |