summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2001-03-04 14:33:15 -0800
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-05 15:33:18 +0000
commitddffee5993cd7260a47b848bbf8a343ef79b4f53 (patch)
tree3245b0c8bc3dfa121f0502352c6bb05c911c8746 /op.c
parent5ba48348b2bf48a04aedce7107ba7c0939e5b567 (diff)
downloadperl-ddffee5993cd7260a47b848bbf8a343ef79b4f53.tar.gz
Re: [ID 20010301.005] corrupt memory (since @8531, in 5.6.1-T2)
Message-Id: <200103050633.f256XFo06998@smtp3.ActiveState.com> PMOPs need to remember their own stash so that they can gracefully remove themselves from their linked list. p4raw-id: //depot/perl@9033
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 4c5dd1302b..13fe21ba5b 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) {
+ 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;
@@ -2934,6 +2957,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;