From 774656327327593b62682336dd494c63c9fa45ad Mon Sep 17 00:00:00 2001 From: Francois Perrad 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 beb988b..6d29905 100644 --- a/regcomp.c +++ b/regcomp.c @@ -13506,7 +13506,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; @@ -13526,8 +13525,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); -- 2.7.4