summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-03-18 05:29:59 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-18 05:29:59 +0000
commitcb55de95c99e46505d72b19ea780c7d46917be32 (patch)
treee53297810981569bf5562f79f5e952a287cf6e75 /op.c
parent60425c380d8403607be85706bb016ae8d577acf4 (diff)
downloadperl-cb55de95c99e46505d72b19ea780c7d46917be32.tar.gz
Sarathy's clear_pmop patch with Radu Greab's fix,
Hiroto's, Nicholas Clark's, and Vadim Konovalov's tests. p4raw-id: //depot/perl@9194
Diffstat (limited to 'op.c')
-rw-r--r--op.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/op.c b/op.c
index 045b8d34b5..25e7aa5058 100644
--- a/op.c
+++ b/op.c
@@ -843,6 +843,29 @@ S_op_clear(pTHX_ OP *o)
case OP_MATCH:
case OP_QR:
clear_pmop:
+ {
+ HV *pmstash = PmopSTASH(cPMOPo);
+ if (pmstash && SvREFCNT(pmstash)) {
+ PMOP *pmop = HvPMROOT(pmstash);
+ PMOP *lastpmop = NULL;
+ while (pmop) {
+ if (cPMOPo == pmop) {
+ if (lastpmop)
+ lastpmop->op_pmnext = pmop->op_pmnext;
+ else
+ HvPMROOT(pmstash) = pmop->op_pmnext;
+ break;
+ }
+ lastpmop = pmop;
+ pmop = pmop->op_pmnext;
+ }
+#ifdef USE_ITHREADS
+ Safefree(PmopSTASHPV(cPMOPo));
+#else
+ /* NOTE: PMOP.op_pmstash is not refcounted */
+#endif
+ }
+ }
cPMOPo->op_pmreplroot = Nullop;
ReREFCNT_dec(cPMOPo->op_pmregexp);
cPMOPo->op_pmregexp = (REGEXP*)NULL;
@@ -2940,6 +2963,7 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags)
if (type != OP_TRANS && PL_curstash) {
pmop->op_pmnext = HvPMROOT(PL_curstash);
HvPMROOT(PL_curstash) = pmop;
+ PmopSTASH_set(pmop,PL_curstash);
}
return (OP*)pmop;