
perlbug-followup at perl
Jun 23, 2012, 6:39 AM
Post #2 of 2
(30 views)
Permalink
|
|
[perl #112962] bad assumption in Perl_reg_temp_copy
[In reply to]
|
|
On Wed May 16 10:01:50 2012, fperrad wrote: > From 84d2d39de77ef762886a6215a787410a5a9563d1 Mon Sep 17 00:00:00 2001 > From: Francois Perrad <francois.perrad [at] gadz> > Date: Wed, 16 May 2012 17:55:22 +0200 > Subject: [PATCH] copy .offs only if not null. > > --- > regcomp.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/regcomp.c b/regcomp.c > index 143f349..c3a258a 100644 > --- a/regcomp.c > +++ b/regcomp.c > @@ -12729,7 +12729,6 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x, > REGEXP *rx) > { > struct regexp *ret; > struct regexp *const r = (struct regexp *)SvANY(rx); > - register const I32 npar = r->nparens+1; > > PERL_ARGS_ASSERT_REG_TEMP_COPY; > > @@ -12749,8 +12748,11 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x, > REGEXP *rx) > SvLEN_set(ret_x, 0); > SvSTASH_set(ret_x, NULL); > SvMAGIC_set(ret_x, NULL); > - Newx(ret->offs, npar, regexp_paren_pair); > - Copy(r->offs, ret->offs, npar, regexp_paren_pair); > + if (r->offs) { > + const I32 npar = r->nparens+1; > + Newx(ret->offs, npar, regexp_paren_pair); > + Copy(r->offs, ret->offs, npar, regexp_paren_pair); > + } > if (r->substrs) { > Newx(ret->substrs, 1, struct reg_substr_data); > StructCopy(r->substrs, ret->substrs, struct reg_substr_data); > -- > 1.7.9.5 Thank you. Applied as 774656327327593. -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=112962
|