Fix a bug which goes unnoticed on all platforms but leads to a

coredump on FreeBSD/amd64 when one uses $^N variable and there were
no captures in the last executed regexp.

One third of this fix was applied to the perl tree in December 2002,
with the rest hopefully applied in the next couple of days.

Reported by:	jwd
This commit is contained in:
Anton Berezin 2003-07-14 11:36:59 +00:00
parent ba16d3d3d0
commit 3b3b7d95e8
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=84872
10 changed files with 160 additions and 5 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VER}
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= lang devel perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN} \
${MASTER_SITE_LOCAL:S/$/:local/} \

View File

@ -0,0 +1,31 @@
--- pp_hot.c.orig Mon Jul 14 10:20:29 2003
+++ pp_hot.c Mon Jul 14 10:21:31 2003
@@ -1406,7 +1406,7 @@ yup: /* Confirmed by INTUIT */
rx->startp[0] = s - truebase;
rx->endp[0] = s - truebase + rx->minlen;
}
- rx->nparens = rx->lastparen = 0; /* used by @- and @+ */
+ rx->nparens = rx->lastparen = rx->lastcloseparen = 0; /* used by @-, @+, and $^N */
LEAVE_SCOPE(oldsave);
RETPUSHYES;
--- sv.c.orig Mon Jul 14 10:21:49 2003
+++ sv.c Mon Jul 14 10:22:35 2003
@@ -11474,6 +11474,7 @@ perl_clone_using(PerlInterpreter *proto_
PL_regstartp = (I32*)NULL;
PL_regendp = (I32*)NULL;
PL_reglastparen = (U32*)NULL;
+ PL_reglastcloseparen = (U32*)NULL;
PL_regtill = Nullch;
PL_reg_start_tmp = (char**)NULL;
PL_reg_start_tmpl = 0;
--- regexec.c.orig Mon Jul 14 10:37:02 2003
+++ regexec.c Mon Jul 14 10:37:34 2003
@@ -2107,6 +2107,7 @@ S_regtry(pTHX_ regexp *prog, char *start
PL_reglastparen = &prog->lastparen;
PL_reglastcloseparen = &prog->lastcloseparen;
prog->lastparen = 0;
+ prog->lastcloseparen = 0;
PL_regsize = 0;
DEBUG_r(PL_reg_starttry = startpos);
if (PL_reg_start_tmpl <= prog->nparens) {

View File

@ -7,7 +7,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VER}
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= lang devel perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN} \
${MASTER_SITE_LOCAL:S/$/:local/} \

View File

@ -0,0 +1,31 @@
--- pp_hot.c.orig Mon Jul 14 10:20:29 2003
+++ pp_hot.c Mon Jul 14 10:21:31 2003
@@ -1406,7 +1406,7 @@ yup: /* Confirmed by INTUIT */
rx->startp[0] = s - truebase;
rx->endp[0] = s - truebase + rx->minlen;
}
- rx->nparens = rx->lastparen = 0; /* used by @- and @+ */
+ rx->nparens = rx->lastparen = rx->lastcloseparen = 0; /* used by @-, @+, and $^N */
LEAVE_SCOPE(oldsave);
RETPUSHYES;
--- sv.c.orig Mon Jul 14 10:21:49 2003
+++ sv.c Mon Jul 14 10:22:35 2003
@@ -11474,6 +11474,7 @@ perl_clone_using(PerlInterpreter *proto_
PL_regstartp = (I32*)NULL;
PL_regendp = (I32*)NULL;
PL_reglastparen = (U32*)NULL;
+ PL_reglastcloseparen = (U32*)NULL;
PL_regtill = Nullch;
PL_reg_start_tmp = (char**)NULL;
PL_reg_start_tmpl = 0;
--- regexec.c.orig Mon Jul 14 10:37:02 2003
+++ regexec.c Mon Jul 14 10:37:34 2003
@@ -2107,6 +2107,7 @@ S_regtry(pTHX_ regexp *prog, char *start
PL_reglastparen = &prog->lastparen;
PL_reglastcloseparen = &prog->lastcloseparen;
prog->lastparen = 0;
+ prog->lastcloseparen = 0;
PL_regsize = 0;
DEBUG_r(PL_reg_starttry = startpos);
if (PL_reg_start_tmpl <= prog->nparens) {

View File

@ -7,7 +7,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VER}
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= lang devel perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN} \
${MASTER_SITE_LOCAL:S/$/:local/} \

View File

@ -0,0 +1,31 @@
--- pp_hot.c.orig Mon Jul 14 10:20:29 2003
+++ pp_hot.c Mon Jul 14 10:21:31 2003
@@ -1406,7 +1406,7 @@ yup: /* Confirmed by INTUIT */
rx->startp[0] = s - truebase;
rx->endp[0] = s - truebase + rx->minlen;
}
- rx->nparens = rx->lastparen = 0; /* used by @- and @+ */
+ rx->nparens = rx->lastparen = rx->lastcloseparen = 0; /* used by @-, @+, and $^N */
LEAVE_SCOPE(oldsave);
RETPUSHYES;
--- sv.c.orig Mon Jul 14 10:21:49 2003
+++ sv.c Mon Jul 14 10:22:35 2003
@@ -11474,6 +11474,7 @@ perl_clone_using(PerlInterpreter *proto_
PL_regstartp = (I32*)NULL;
PL_regendp = (I32*)NULL;
PL_reglastparen = (U32*)NULL;
+ PL_reglastcloseparen = (U32*)NULL;
PL_regtill = Nullch;
PL_reg_start_tmp = (char**)NULL;
PL_reg_start_tmpl = 0;
--- regexec.c.orig Mon Jul 14 10:37:02 2003
+++ regexec.c Mon Jul 14 10:37:34 2003
@@ -2107,6 +2107,7 @@ S_regtry(pTHX_ regexp *prog, char *start
PL_reglastparen = &prog->lastparen;
PL_reglastcloseparen = &prog->lastcloseparen;
prog->lastparen = 0;
+ prog->lastcloseparen = 0;
PL_regsize = 0;
DEBUG_r(PL_reg_starttry = startpos);
if (PL_reg_start_tmpl <= prog->nparens) {

View File

@ -7,7 +7,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VER}
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= lang devel perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN} \
${MASTER_SITE_LOCAL:S/$/:local/} \

View File

@ -0,0 +1,31 @@
--- pp_hot.c.orig Mon Jul 14 10:20:29 2003
+++ pp_hot.c Mon Jul 14 10:21:31 2003
@@ -1406,7 +1406,7 @@ yup: /* Confirmed by INTUIT */
rx->startp[0] = s - truebase;
rx->endp[0] = s - truebase + rx->minlen;
}
- rx->nparens = rx->lastparen = 0; /* used by @- and @+ */
+ rx->nparens = rx->lastparen = rx->lastcloseparen = 0; /* used by @-, @+, and $^N */
LEAVE_SCOPE(oldsave);
RETPUSHYES;
--- sv.c.orig Mon Jul 14 10:21:49 2003
+++ sv.c Mon Jul 14 10:22:35 2003
@@ -11474,6 +11474,7 @@ perl_clone_using(PerlInterpreter *proto_
PL_regstartp = (I32*)NULL;
PL_regendp = (I32*)NULL;
PL_reglastparen = (U32*)NULL;
+ PL_reglastcloseparen = (U32*)NULL;
PL_regtill = Nullch;
PL_reg_start_tmp = (char**)NULL;
PL_reg_start_tmpl = 0;
--- regexec.c.orig Mon Jul 14 10:37:02 2003
+++ regexec.c Mon Jul 14 10:37:34 2003
@@ -2107,6 +2107,7 @@ S_regtry(pTHX_ regexp *prog, char *start
PL_reglastparen = &prog->lastparen;
PL_reglastcloseparen = &prog->lastcloseparen;
prog->lastparen = 0;
+ prog->lastcloseparen = 0;
PL_regsize = 0;
DEBUG_r(PL_reg_starttry = startpos);
if (PL_reg_start_tmpl <= prog->nparens) {

View File

@ -7,7 +7,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VER}
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= lang devel perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN} \
${MASTER_SITE_LOCAL:S/$/:local/} \

View File

@ -0,0 +1,31 @@
--- pp_hot.c.orig Mon Jul 14 10:20:29 2003
+++ pp_hot.c Mon Jul 14 10:21:31 2003
@@ -1406,7 +1406,7 @@ yup: /* Confirmed by INTUIT */
rx->startp[0] = s - truebase;
rx->endp[0] = s - truebase + rx->minlen;
}
- rx->nparens = rx->lastparen = 0; /* used by @- and @+ */
+ rx->nparens = rx->lastparen = rx->lastcloseparen = 0; /* used by @-, @+, and $^N */
LEAVE_SCOPE(oldsave);
RETPUSHYES;
--- sv.c.orig Mon Jul 14 10:21:49 2003
+++ sv.c Mon Jul 14 10:22:35 2003
@@ -11474,6 +11474,7 @@ perl_clone_using(PerlInterpreter *proto_
PL_regstartp = (I32*)NULL;
PL_regendp = (I32*)NULL;
PL_reglastparen = (U32*)NULL;
+ PL_reglastcloseparen = (U32*)NULL;
PL_regtill = Nullch;
PL_reg_start_tmp = (char**)NULL;
PL_reg_start_tmpl = 0;
--- regexec.c.orig Mon Jul 14 10:37:02 2003
+++ regexec.c Mon Jul 14 10:37:34 2003
@@ -2107,6 +2107,7 @@ S_regtry(pTHX_ regexp *prog, char *start
PL_reglastparen = &prog->lastparen;
PL_reglastcloseparen = &prog->lastcloseparen;
prog->lastparen = 0;
+ prog->lastcloseparen = 0;
PL_regsize = 0;
DEBUG_r(PL_reg_starttry = startpos);
if (PL_reg_start_tmpl <= prog->nparens) {