From 7437becc789e98e37551293e8c645c4aa36fdd5d Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Thu, 25 Aug 2005 14:06:43 +0000 Subject: [PATCH] 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 --- sv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.7.4