This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
panic if we attempt to sv_setsv to or from an already freed SV.
authorNicholas Clark <nick@ccl4.org>
Wed, 18 Oct 2006 17:35:06 +0000 (17:35 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 18 Oct 2006 17:35:06 +0000 (17:35 +0000)
p4raw-id: //depot/perl@29040

sv.c

diff --git a/sv.c b/sv.c
index 52fa64f..8820f2a 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3406,9 +3406,18 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
 
     if (sstr == dstr)
        return;
+
+    if (SvIS_FREED(dstr)) {
+       Perl_croak(aTHX_ "panic: attempt to copy value %" SVf
+                  " to a freed scalar %p", sstr, dstr);
+    }
     SV_CHECK_THINKFIRST_COW_DROP(dstr);
     if (!sstr)
        sstr = &PL_sv_undef;
+    if (SvIS_FREED(sstr)) {
+       Perl_croak(aTHX_ "panic: attempt to copy freed scalar %p to %p", sstr,
+                  dstr);
+    }
     stype = SvTYPE(sstr);
     dtype = SvTYPE(dstr);