Re: thread free problem
[p5sagit/p5-mst-13.2.git] / op.c
diff --git a/op.c b/op.c
index 5325a5a..32bf1d8 100644 (file)
--- a/op.c
+++ b/op.c
@@ -490,7 +490,16 @@ clear_pmop:
 STATIC void
 S_cop_free(pTHX_ COP* cop)
 {
-    Safefree(cop->cop_label);   /* FIXME: treaddead ??? */
+    if (cop->cop_label) {
+#ifdef PERL_TRACK_MEMPOOL
+       Malloc_t ptr = (Malloc_t)(cop->cop_label - sTHX);
+       struct perl_memory_debug_header *const header
+               = (struct perl_memory_debug_header *)ptr;
+       /* Only the thread that allocated us can free us. */
+       if (header->interpreter == aTHX)
+#endif
+           Safefree(cop->cop_label);
+    }
     CopFILE_free(cop);
     CopSTASH_free(cop);
     if (! specialWARN(cop->cop_warnings))