From d144199dfbefd276669a138b042f559b687b8bc8 Mon Sep 17 00:00:00 2001
From: Zoltan Herczeg <zherczeg.u-szeged@partner.samsung.com>
Date: Wed, 24 Nov 2021 17:58:30 +0100
Subject: [PATCH] Revert an unintended change in JIT repeat detection. (#58)

Co-authored-by: Zoltan Herczeg <hzmester@freemail.hu>

Conflict:delete changelog
Reference:https://github.com/PCRE2Project/pcre2/commit/d144199dfbefd276669a138b042f559b687b8bc8
---
 src/pcre2_jit_compile.c | 2 +-
 src/pcre2_jit_test.c    | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c
index 6c42318..ac75c7f 100644
--- a/src/pcre2_jit_compile.c
+++ b/src/pcre2_jit_compile.c
@@ -1624,7 +1624,7 @@ if (end[-(1 + LINK_SIZE)] != OP_KET || PRIVATE_DATA(begin) != 0)
 
 /* /(?:AB){4,6}/ is currently converted to /(?:AB){3}(?AB){1,3}/
  * Skip the check of the second part. */
-if (PRIVATE_DATA(end - LINK_SIZE) == 0)
+if (PRIVATE_DATA(end - LINK_SIZE) != 0)
   return TRUE;
 
 next = end;
diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c
index 26de6c7..f7b9f6d 100644
--- a/src/pcre2_jit_test.c
+++ b/src/pcre2_jit_test.c
@@ -291,6 +291,7 @@ static struct regression_test_case regression_test_cases[] = {
 	{ MU, A, 0, 0, "(a(?:bc|cb|b|c)+?|ss)+e", "accssabccbcacbccbbXaccssabccbcacbccbbe" },
 	{ MU, A, 0, 0, "(a(?:bc|cb|b|c)+|ss)+?e", "accssabccbcacbccbbXaccssabccbcacbccbbe" },
 	{ MU, A, 0, 0, "(?:(b(c)+?)+)?\?(?:(bc)+|(cb)+)+(?:m)+", "bccbcccbcbccbcbPbccbcccbcbccbcbmmn" },
+	{ MU, A, 0, 0, "(aa|bb){8,1000}", "abaabbaabbaabbaab_aabbaabbaabbaabbaabbaabb_" },
 
 	/* Greedy and non-greedy * operators */
 	{ CMU, A, 0, 0, "(?:AA)*AB", "aaaaaaamaaaaaaab" },
-- 
2.27.0

