This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Set PL_curcop to NULL in op.c:S_cop_free
authorFather Chrysostomos <sprout@cpan.org>
Sat, 10 Aug 2013 17:41:11 +0000 (10:41 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 17:53:34 +0000 (10:53 -0700)
Having PL_curcop pointing to a freed op is a Bad Idea and something
that has caused bugs in the past.

The intent of commit 1df5f7c195 was to do this, but this part of
the commit was accidentally omitted.

See <20130805200313.GS3729@plum.flirble.org>.

op.c

diff --git a/op.c b/op.c
index 1064aff..f5a274f 100644 (file)
--- a/op.c
+++ b/op.c
@@ -925,6 +925,8 @@ S_cop_free(pTHX_ COP* cop)
     if (! specialWARN(cop->cop_warnings))
        PerlMemShared_free(cop->cop_warnings);
     cophh_free(CopHINTHASH_get(cop));
+    if (PL_curcop == cop)
+       PL_curcop = NULL;
 }
 
 STATIC void