From: Nicholas Clark Date: Thu, 25 Aug 2005 14:06:43 +0000 (+0000) Subject: To make the current implementation of sv_replace sane, we should X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7437becc789e98e37551293e8c645c4aa36fdd5d;p=p5sagit%2Fp5-mst-13.2.git To make the current implementation of sv_replace sane, we should assert that the reference count of the target is also 1. (Given that we're splatting an SV with a reference count of 1 onto the target) p4raw-id: //depot/perl@25331 --- diff --git a/sv.c b/sv.c index 5089825..66f3dc0 100644 --- a/sv.c +++ b/sv.c @@ -5409,9 +5409,13 @@ Perl_sv_replace(pTHX_ register SV *sv, register SV *nsv) const U32 refcnt = SvREFCNT(sv); SV_CHECK_THINKFIRST_COW_DROP(sv); if (SvREFCNT(nsv) != 1) { - Perl_croak(aTHX_ "panic: feference miscount on nsv in sv_replace() (%" + Perl_croak(aTHX_ "panic: reference miscount on nsv in sv_replace() (%" UVuf " != 1)", (UV) SvREFCNT(nsv)); } + if (SvREFCNT(sv) != 1) { + Perl_croak(aTHX_ "panic: reference miscount on sv in sv_replace() (%" + UVuf " != 1)", (UV) SvREFCNT(sv)); + } if (SvMAGICAL(sv)) { if (SvMAGICAL(nsv)) mg_free(nsv);