From dc733f5637bde32a097b2f84c837e8659c22ac61 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Fri, 1 Mar 2024 17:23:34 +0000 Subject: [PATCH] Backport of pcre2-10.44-Fix-incorrect-compiling.patch Cherry-pick of 4a6a8b056f39079d5e958eac84c2ad173f4680bc Fix incorrect compiling when variable-length lookbehind's first branch was not the shortest and there was a backreference to a groupwithin the lookbehind. --- src/pcre2_compile.c | 2 +- testdata/testinput2 | 4 ++++ testdata/testoutput2 | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 8b364977..71c2dbca 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -9908,7 +9908,7 @@ do *bptr |= branchlength; /* branchlength never more than 65535 */ bptr = *pptrptr; } -while (*bptr == META_ALT); +while (META_CODE(*bptr) == META_ALT); /* If any branch is of variable length, the whole lookbehind is of variable length. If the maximum length of any branch exceeds the maximum for variable diff --git a/testdata/testinput2 b/testdata/testinput2 index 97608542..9b4c0684 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -6099,4 +6099,8 @@ a)"xI /(a(?1)z||(?1)++)$/ abcd\=disable_recurseloop_check +/(((?<=123?456456|ABC)))(?<=\2)../ + ABCDEFG + 12345645678910 + # End of testinput2 diff --git a/testdata/testoutput2 b/testdata/testoutput2 index ee1f70b0..30c5a83e 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -18038,6 +18038,16 @@ Failed: error -47: match limit exceeded 0: 1: +/(((?<=123?456456|ABC)))(?<=\2)../ + ABCDEFG + 0: DE + 1: + 2: + 12345645678910 + 0: 78 + 1: + 2: + # End of testinput2 Error -70: PCRE2_ERROR_BADDATA (unknown error number) Error -62: bad serialized data -- 2.56.0