From: Doug MacEachern Date: Fri, 3 Aug 2001 18:17:41 +0000 (-0700) Subject: [patch] refcount re ops X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b978d731dbdb96e716e0b0959a0135ca6805247;p=p5sagit%2Fp5-mst-13.2.git [patch] refcount re ops Message-ID: p4raw-id: //depot/perl@11568 --- diff --git a/regcomp.c b/regcomp.c index cdf42f5..fb6b9c5 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2138,6 +2138,9 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp) ENTER; Perl_save_re_context(aTHX); rop = sv_compile_2op(sv, &sop, "re", &av); + sop->op_private |= OPpREFCOUNTED; + /* re_dup will OpREFCNT_inc */ + OpREFCNT_set(sop, 1); LEAVE; n = add_data(pRExC_state, 3, "nop"); @@ -4609,7 +4612,11 @@ Perl_pregfree(pTHX_ struct regexp *r) } else PL_curpad = NULL; - op_free((OP_4tree*)r->data->data[n]); + + if (!OpREFCNT_dec((OP_4tree*)r->data->data[n])) { + op_free((OP_4tree*)r->data->data[n]); + } + PL_comppad = old_comppad; PL_curpad = old_curpad; SvREFCNT_dec((SV*)new_comppad); diff --git a/sv.c b/sv.c index 33a87b8..1194657 100644 --- a/sv.c +++ b/sv.c @@ -8403,6 +8403,9 @@ Perl_re_dup(pTHX_ REGEXP *r, clone_params *param) ret->regstclass = (regnode*)d->data[i]; break; case 'o': + /* XXX: can this really be shared? */ + d->data[i] = (void*)OpREFCNT_inc((OP*)r->data->data[i]); + break; case 'n': d->data[i] = r->data->data[i]; break;