This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Call cop_free on nullified cops too
[perl5.git] / op.c
diff --git a/op.c b/op.c
index 6823cc9..ba9e2a5 100644 (file)
--- a/op.c
+++ b/op.c
@@ -502,7 +502,10 @@ Perl_op_free(pTHX_ OP *o)
 
     /* COP* is not cleared by op_clear() so that we may track line
      * numbers etc even after null() */
-    if (type == OP_NEXTSTATE || type == OP_DBSTATE) {
+    if (type == OP_NEXTSTATE || type == OP_DBSTATE
+           || (type == OP_NULL /* the COP might have been null'ed */
+               && ((OPCODE)o->op_targ == OP_NEXTSTATE
+                   || (OPCODE)o->op_targ == OP_DBSTATE))) {
        cop_free((COP*)o);
     }