summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>1999-02-17 10:06:01 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-02-17 21:18:21 +0000
commitdfad63adc8924929eac70ad8db0652253a4efff0 (patch)
treee6bee02f444f53965585421a16f6ce5ca5e04cfd /regcomp.c
parentf4ea8be436d63a2d4ad8e73df68153800c505ef9 (diff)
downloadperl-dfad63adc8924929eac70ad8db0652253a4efff0.tar.gz
fix comppad handling for failures in eval 'qr/(?p{...})/'
Message-Id: <199902171006.KAA10204@crypt.compulink.co.uk> Subject: Re: [5.005_53] panic: pad_free curpad p4raw-id: //depot/perl@2963
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/regcomp.c b/regcomp.c
index 5d4c0f0dac..5b4bdf397b 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -1171,10 +1171,10 @@ reg(I32 paren, I32 *flagp)
rop = sv_compile_2op(sv, &sop, "re", &av);
- n = add_data(3, "nso");
+ n = add_data(3, "nop");
PL_regcomp_rx->data->data[n] = (void*)rop;
- PL_regcomp_rx->data->data[n+1] = (void*)av;
- PL_regcomp_rx->data->data[n+2] = (void*)sop;
+ PL_regcomp_rx->data->data[n+1] = (void*)sop;
+ PL_regcomp_rx->data->data[n+2] = (void*)av;
SvREFCNT_dec(sv);
}
else { /* First pass */
@@ -3123,13 +3123,30 @@ pregfree(struct regexp *r)
}
if (r->data) {
int n = r->data->count;
+ AV* new_comppad = NULL;
+ AV* old_comppad;
+ SV** old_curpad;
+
while (--n >= 0) {
switch (r->data->what[n]) {
case 's':
SvREFCNT_dec((SV*)r->data->data[n]);
break;
+ case 'p':
+ new_comppad = (AV*)r->data->data[n];
+ break;
case 'o':
+ if (new_comppad == NULL)
+ croak("panic: pregfree comppad");
+ old_comppad = PL_comppad;
+ old_curpad = PL_curpad;
+ PL_comppad = new_comppad;
+ PL_curpad = AvARRAY(new_comppad);
op_free((OP_4tree*)r->data->data[n]);
+ PL_comppad = old_comppad;
+ PL_curpad = old_curpad;
+ SvREFCNT_dec((SV*)new_comppad);
+ new_comppad = NULL;
break;
case 'n':
break;