develooper Front page | perl.perl5.porters | Postings from June 2012

[perl #112962] bad assumption in Perl_reg_temp_copy

From:
Father Chrysostomos via RT
Date:
June 23, 2012 06:39
Subject:
[perl #112962] bad assumption in Perl_reg_temp_copy
Message ID:
rt-3.6.HEAD-5009-1340458739-1838.112962-15-0@perl.org
On Wed May 16 10:01:50 2012, fperrad wrote:
> From 84d2d39de77ef762886a6215a787410a5a9563d1 Mon Sep 17 00:00:00 2001
> From: Francois Perrad <francois.perrad@gadz.org>
> 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



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About