This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [perl #9394] Re: [ID 20020525.002] coredump/ bad free warning in blead with...
[perl5.git] / sv.c
diff --git a/sv.c b/sv.c
index 36c9f80..ce7540c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -7883,7 +7883,9 @@ Perl_sv_unref_flags(pTHX_ SV *sv, U32 flags)
     }
     SvRV(sv) = 0;
     SvROK_off(sv);
-    if (SvREFCNT(rv) != 1 || SvREADONLY(rv) || (flags & SV_IMMEDIATE_UNREF))
+    /* You can't have a || SvREADONLY(rv) here, as $a = $$a, where $a was
+       assigned to as BEGIN {$a = \"Foo"} will fail.  */
+    if (SvREFCNT(rv) != 1 || (flags & SV_IMMEDIATE_UNREF))
        SvREFCNT_dec(rv);
     else /* XXX Hack, but hard to make $a=$a->[1] work otherwise */
        sv_2mortal(rv);         /* Schedule for freeing later */