From 741390ca2d8158580db6e523046fba90e31258e4 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Thu, 16 Nov 2023 08:02:01 +0000 Subject: [PATCH] Fix vreverse issues --- src/pcre2_jit_compile.c | 12 ++++++------ src/pcre2_jit_test.c | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c index 1da782224..510c39213 100644 --- a/src/pcre2_jit_compile.c +++ b/src/pcre2_jit_compile.c @@ -9869,9 +9869,9 @@ SLJIT_ASSERT(parent->top == NULL); if (*cc == OP_REVERSE) { reverse_failed = &parent->topbacktracks; - lmin = GET(cc, 1); + lmin = GET2(cc, 1); lmax = lmin; - cc += 1 + LINK_SIZE; + cc += 1 + IMM2_SIZE; SLJIT_ASSERT(lmin > 0); } @@ -9881,9 +9881,9 @@ else PUSH_BACKTRACK(sizeof(vreverse_backtrack), cc, NULL); reverse_failed = &backtrack->topbacktracks; - lmin = GET(cc, 1); - lmax = GET(cc, 1 + IMM2_SIZE); - cc += 1 + 2 * LINK_SIZE; + lmin = GET2(cc, 1); + lmax = GET2(cc, 1 + IMM2_SIZE); + cc += 1 + 2 * IMM2_SIZE; SLJIT_ASSERT(lmin < lmax); } @@ -10211,7 +10211,7 @@ while (1) if (conditional) { if (extrasize > 0) - OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), needs_control_head ? STACK(-2) : STACK(-1)); + OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(-end_block_size - (needs_control_head ? 2 : 1))); } else if (bra == OP_BRAZERO) { diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c index 966869a09..b27cec7b5 100644 --- a/src/pcre2_jit_test.c +++ b/src/pcre2_jit_test.c @@ -631,6 +631,7 @@ static struct regression_test_case regression_test_cases[] = { { MU, A, 0, 0, "c(?(?!\\b|(?C)\\B(?C`x`))ab|a)", "cab" }, { MU, A, 0, 0, "a(?=)b", "ab" }, { MU, A, 0, 0 | F_NOMATCH, "a(?!)b", "ab" }, + { MU, A, 0, 0, "(?(?