Front page | perl.perl5.porters |
Postings from May 2012
[perl #112962] bad assumption in Perl_reg_temp_copy
Thread Next
From:
James E Keenan via RT
Date:
May 23, 2012 20:10
Subject:
[perl #112962] bad assumption in Perl_reg_temp_copy
Message ID:
rt-3.6.HEAD-7788-1337829005-81.112962-15-0@perl.org
On Wed May 16 10:01:50 2012, fperrad wrote:
> This is a bug report for perl from perrad@cpan.org,
> generated with the help of perlbug 1.39 running under perl 5.14.2.
>
>
> -----------------------------------------------------------------
> [Please describe your issue here]
> When I update my module re::engine::Lua for Perl 5.12 & 5.14,
> qr// segfaults in the function Perl_reg_temp_copy (regcomp.c).
> Because this function assumes that the field offs of REGEXP
> is always set by the method comp of the regex_engine.
> But in re::engine::Lua, offs is set by the method exec.
>
> re::engine::Lua 0.08 includes a workaround,
> but I propose a patch.
>
[snip]
>
> Locally applied patches:
> 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
>
I tested this patch on blead on Darwin/PPC and it passed all current
tests. It should be evaluated by others for how well it deals with the
problem François described.
Thank you very much.
Jim Keenan
---
via perlbug: queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=112962
Thread Next
-
[perl #112962] bad assumption in Perl_reg_temp_copy
by James E Keenan via RT