summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-06-15 16:33:29 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-06-15 16:33:29 +0000
commit0cf340fbea16a8cc18935f2b02367a660f910474 (patch)
treebfeb96aecb1715a261121b829379c48b7bf947b4
parent0761e6b73e7b93571f116e2307f0c660c898f7ae (diff)
downloadpcre-0cf340fbea16a8cc18935f2b02367a660f910474.tar.gz
Avoid loop caused by (*SKIP) with an argument.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@543 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--pcre_exec.c29
-rw-r--r--testdata/testinput115
-rw-r--r--testdata/testoutput116
3 files changed, 30 insertions, 10 deletions
diff --git a/pcre_exec.c b/pcre_exec.c
index cdd66ce..8b5bae2 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -6069,13 +6069,28 @@ for(;;)
switch(rc)
{
- /* NOMATCH and PRUNE advance by one character. If MATCH_SKIP_ARG reaches
- this level it means that a MARK that matched the SKIP's arg was not found.
- We treat this as NOMATCH. THEN at this level acts exactly like PRUNE. */
+ /* SKIP passes back the next starting point explicitly, but if it is the
+ same as the match we have just done, treat it as NOMATCH. */
+
+ case MATCH_SKIP:
+ if (md->start_match_ptr != start_match)
+ {
+ new_start_match = md->start_match_ptr;
+ break;
+ }
+ /* Fall through */
+
+ /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched
+ the SKIP's arg was not found. We also treat this as NOMATCH. */
+
+ case MATCH_SKIP_ARG:
+ /* Fall through */
+
+ /* NOMATCH and PRUNE advance by one character. THEN at this level acts
+ exactly like PRUNE. */
case MATCH_NOMATCH:
case MATCH_PRUNE:
- case MATCH_SKIP_ARG:
case MATCH_THEN:
new_start_match = start_match + 1;
#ifdef SUPPORT_UTF8
@@ -6085,12 +6100,6 @@ for(;;)
#endif
break;
- /* SKIP passes back the next starting point explicitly. */
-
- case MATCH_SKIP:
- new_start_match = md->start_match_ptr;
- break;
-
/* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
case MATCH_COMMIT:
diff --git a/testdata/testinput11 b/testdata/testinput11
index 43d08f3..c074176 100644
--- a/testdata/testinput11
+++ b/testdata/testinput11
@@ -435,6 +435,11 @@ with the handling of backtracking verbs. ---/
/A(*:A)A+(*SKIP:A)(B|Z) | AC/xK
AAAC
+/--- Don't loop! ---/
+
+/(*:A)A+(*SKIP:A)(B|Z)/K
+ AAAC
+
/--- This should succeed, as a non-existent skip name disables the skip ---/
/A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/xK
diff --git a/testdata/testoutput11 b/testdata/testoutput11
index 5821d44..8b0f111 100644
--- a/testdata/testoutput11
+++ b/testdata/testoutput11
@@ -864,6 +864,12 @@ with the handling of backtracking verbs. ---/
AAAC
0: AC
+/--- Don't loop! ---/
+
+/(*:A)A+(*SKIP:A)(B|Z)/K
+ AAAC
+No match, mark = A
+
/--- This should succeed, as a non-existent skip name disables the skip ---/
/A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/xK