summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorYves Orton <yves.orton@booking.com>2014-02-04 16:18:16 +0800
committerYves Orton <yves.orton@booking.com>2014-02-04 17:01:36 +0800
commitcdba0a877ca73eb043337ab9136c0bf1231edd11 (patch)
tree16ef7d68e31a460e49080bc089b3f11fba3ab4d9 /regcomp.c
parentc60b4fa6f71ef321ed0d72b47de4268c71d26e63 (diff)
downloadperl-cdba0a877ca73eb043337ab9136c0bf1231edd11.tar.gz
do not overflow when the pattern is unbounded
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/regcomp.c b/regcomp.c
index 92e3ef414b..ba63f1f11e 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5394,10 +5394,9 @@ PerlIO_printf(Perl_debug_log, "LHS=%"UVdf" RHS=%"UVdf"\n",
{
SSize_t final_minlen= min < stopmin ? min : stopmin;
- if (RExC_maxlen < final_minlen + delta) {
+ if (!(RExC_seen & REG_UNBOUNDED_QUANTIFIER_SEEN) && (RExC_maxlen < final_minlen + delta)) {
RExC_maxlen = final_minlen + delta;
}
-
return final_minlen;
}
/* not-reached */
@@ -7030,6 +7029,14 @@ reStudy:
}
}
+ if (RExC_seen & REG_UNBOUNDED_QUANTIFIER_SEEN) {
+ r->extflags |= RXf_UNBOUNDED_QUANTIFIER_SEEN;
+ r->maxlen = REG_INFTY;
+ }
+ else {
+ r->maxlen = RExC_maxlen;
+ }
+
/* Guard against an embedded (?=) or (?<=) with a longer minlen than
the "real" pattern. */
DEBUG_OPTIMISE_r({
@@ -7040,8 +7047,6 @@ reStudy:
if (r->minlen < minlen)
r->minlen = minlen;
-
-
if (RExC_seen & REG_GPOS_SEEN)
r->intflags |= PREGf_GPOS_SEEN;
if (RExC_seen & REG_LOOKBEHIND_SEEN)
@@ -7065,9 +7070,6 @@ reStudy:
else
RXp_PAREN_NAMES(r) = NULL;
- if (RExC_seen & REG_UNBOUNDED_QUANTIFIER_SEEN)
- r->extflags |= RXf_UNBOUNDED_QUANTIFIER_SEEN;
-
/* If we have seen an anchor in our pattern then we set the extflag RXf_IS_ANCHORED
* so it can be used in pp.c */
if (r->intflags & PREGf_ANCH)