summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>1998-07-01 22:14:05 +0200
committerGurusamy Sarathy <gsar@cpan.org>1998-07-04 05:06:52 +0000
commitef64f398041e39403718b830b0e15752f4a1cfbf (patch)
treeedae921f2c92546db97eaed67cedba0012d6d7fd /regcomp.c
parenta45b45bb1348651ebb0ab7ec1221fce2376aa4a1 (diff)
downloadperl-ef64f398041e39403718b830b0e15752f4a1cfbf.tar.gz
catch nonexistent backrefs in REs
Message-Id: <l03130304b1c027e1df9e@[194.222.64.89]> Date: Wed, 1 Jul 1998 20:14:05 +0200 Subject: Re: [PATCH _66] for bad backrefs -- Message-Id: <l03130300b1c03425261c@[194.222.64.89]> Date: Wed, 1 Jul 1998 20:47:16 +0200 Subject: Re: [PATCH _66] for bad backrefs p4raw-id: //depot/perl@1293
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/regcomp.c b/regcomp.c
index ca4da9c97a..0a36cbbb4d 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -765,6 +765,7 @@ pregcomp(char *exp, char *xend, PMOP *pm)
r->prelen = xend - exp;
r->precomp = regprecomp;
r->subbeg = r->subbase = NULL;
+ r->nparens = regnpar - 1; /* set early to validate backrefs */
regcomp_rx = r;
/* Second pass: emit code. */
@@ -936,7 +937,6 @@ pregcomp(char *exp, char *xend, PMOP *pm)
r->check_substr = r->anchored_substr = r->float_substr = Nullsv;
}
- r->nparens = regnpar - 1;
r->minlen = minlen;
if (regseen & REG_SEEN_GPOS)
r->reganch |= ROPT_GPOS_SEEN;
@@ -1609,6 +1609,8 @@ tryagain:
if (num > 9 && num >= regnpar)
goto defchar;
else {
+ if (!SIZE_ONLY && num > regcomp_rx->nparens)
+ FAIL("reference to nonexistent group");
regsawback = 1;
ret = reganode((regflags & PMf_FOLD)
? ((regflags & PMf_LOCALE) ? REFFL : REFF)