summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2021-02-18 09:46:08 +0000
committerph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2021-02-18 09:46:08 +0000
commit1ef05f50d623582e8493ab49cfe0c243eed175c9 (patch)
tree74eac9477ae11cf28b6a36ce18379e0572c38513
parente76709c3107e505dbaa3e090548e405d254419a7 (diff)
downloadpcre2-1ef05f50d623582e8493ab49cfe0c243eed175c9.tar.gz
Fix \K within recursion bug in interpreter.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1301 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r--ChangeLog4
-rw-r--r--src/pcre2_match.c4
-rw-r--r--testdata/testinput13
-rw-r--r--testdata/testoutput14
4 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bcf9db8..0891adf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,10 @@ now runs clean and the resulting "configure" seems to work, so I hope nothing
is broken. Later: the requirement for autoconf 2.70 broke some automatic test
robots. It doesn't seem to be necessary: trying a reduction to 2.60.
+6. The pattern /a\K.(?0)*/ when matched against "abac" by the interpreter gave
+the answer "bac", whereas Perl and JIT both yield "c". This was because the
+effect of \K was not propagating back from the recursion. This is now fixed.
+
Version 10.36 04-December-2020
------------------------------
diff --git a/src/pcre2_match.c b/src/pcre2_match.c
index e3f78c2..7d9cad0 100644
--- a/src/pcre2_match.c
+++ b/src/pcre2_match.c
@@ -818,10 +818,12 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
/* N is now the frame of the recursion; the previous frame is at the
OP_RECURSE position. Go back there, copying the current subject position
- and mark, and move on past the OP_RECURSE. */
+ and mark, and the start_match position (\K might have changed it), and
+ then move on past the OP_RECURSE. */
P->eptr = Feptr;
P->mark = Fmark;
+ P->start_match = Fstart_match;
F = P;
Fecode += 1 + LINK_SIZE;
continue;
diff --git a/testdata/testinput1 b/testdata/testinput1
index bb4ddb7..4cf1126 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -6429,4 +6429,7 @@ ef) x/x,mark
/a{65536/
>a{65536<
+/a\K.(?0)*/
+ abac
+
# End of testinput1
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index 05b310b..8d4c108 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -10188,4 +10188,8 @@ No match
>a{65536<
0: a{65536
+/a\K.(?0)*/
+ abac
+ 0: c
+
# End of testinput1