From 3b1cc1e637751ccdbf9c842f54b9c5b1e5a1d621 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Wed, 20 May 2026 10:03:53 +0000 Subject: [PATCH] Fix setting STR_END in JIT When OP_VREVERSE is present in a non-atomic LOOKBEHIND ASSERTION, the STR_END must be set before the backtracking path is executed. --- src/pcre2_jit_compile.c | 2 ++ src/pcre2_jit_test.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c index 5d8c1c14c..9013b6864 100644 --- a/src/pcre2_jit_compile.c +++ b/src/pcre2_jit_compile.c @@ -12520,6 +12520,8 @@ else if (SLJIT_UNLIKELY(opcode == OP_ASSERT_SCS)) if (common->restore_end_ptr == 0) common->restore_end_ptr = private_data_ptr + sizeof(sljit_sw); } +else if (SLJIT_UNLIKELY(opcode == OP_ASSERTBACK_NA) && PRIVATE_DATA(ccbegin + 1)) + OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr); if (SLJIT_UNLIKELY(opcode == OP_ONCE)) { diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c index 03cc348b0..7c4bcd684 100644 --- a/src/pcre2_jit_test.c +++ b/src/pcre2_jit_test.c @@ -657,6 +657,7 @@ static struct regression_test_case regression_test_cases[] = { { MU, A, 0, 0 | F_NOMATCH, "a(?!)b", "ab" }, { MU, A, 0, 0, "(?(?