summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2019-09-07 15:16:10 +0000
committerph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2019-09-07 15:16:10 +0000
commit369fe5f8aa93cfba50f9db391ac54afb852222fa (patch)
treedfae2d0e99ec6254c92ea5f39d6f76ea304cf563 /src
parenta99a69110bfb2f3571677be67ece3d4013a3ce1a (diff)
downloadpcre2-369fe5f8aa93cfba50f9db391ac54afb852222fa.tar.gz
When computing minimum length, don't scan subsequent branches if any branch in
a group has zero minimum length. git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1165 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src')
-rw-r--r--src/pcre2_study.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pcre2_study.c b/src/pcre2_study.c
index 280ad57..6370e17 100644
--- a/src/pcre2_study.c
+++ b/src/pcre2_study.c
@@ -223,7 +223,9 @@ for (;;)
/* Reached end of a branch; if it's a ket it is the end of a nested
call. If it's ALT it is an alternation in a nested call. If it is END it's
- the end of the outer call. All can be handled by the same code. */
+ the end of the outer call. All can be handled by the same code. If the
+ length of any branch is zero, there is no need to scan any subsequent
+ branches. */
case OP_ALT:
case OP_KET:
@@ -233,7 +235,7 @@ for (;;)
case OP_END:
if (length < 0 || (!had_recurse && branchlength < length))
length = branchlength;
- if (op != OP_ALT) return length;
+ if (op != OP_ALT || length == 0) return length;
nextbranch = cc + GET(cc, 1);
cc += 1 + LINK_SIZE;
branchlength = 0;