From e40bc47ae24acd9315aec44780aa047b016ba35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Herczeg?= Date: Wed, 26 Aug 2015 13:35:58 +0000 Subject: [PATCH] Fixed a corner case of range optimization in JIT. --- ChangeLog | 2 ++ src/pcre2_jit_compile.c | 2 ++ src/pcre2_jit_test.c | 1 + 3 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index bc04314..b53f922 100644 --- a/ChangeLog +++ b/ChangeLog @@ -160,6 +160,8 @@ III). 44. Fix bug in RunTest.bat for new test 14, and adjust the script for the added test (there are now 20 in total). +45. Fixed a corner case of range optimization in JIT. + Version 10.20 30-June-2015 -------------------------- diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c index 3bfb834..21b5a40 100644 --- a/src/pcre2_jit_compile.c +++ b/src/pcre2_jit_compile.c @@ -4997,8 +4997,10 @@ switch(length) case 4: if ((ranges[1] - ranges[0]) == (ranges[3] - ranges[2]) && (ranges[0] | (ranges[2] - ranges[0])) == ranges[2] + && (ranges[1] & (ranges[2] - ranges[0])) == 0 && is_powerof2(ranges[2] - ranges[0])) { + SLJIT_ASSERT((ranges[0] & (ranges[2] - ranges[0])) == 0 && (ranges[2] & ranges[3] & (ranges[2] - ranges[0])) != 0); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[0]); if (ranges[2] + 1 != ranges[3]) { diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c index 6c9f68b..98bb964 100644 --- a/src/pcre2_jit_test.c +++ b/src/pcre2_jit_test.c @@ -188,6 +188,7 @@ static struct regression_test_case regression_test_cases[] = { { CMUP, A, 0, 0, "\xf0\x90\x90\x80{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" }, { CMUP, A, 0, 0, "\xf0\x90\x90\xa8{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" }, { CMUP, A, 0, 0, "\xe1\xbd\xb8\xe1\xbf\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" }, + { M, A, 0, 0, "[3-57-9]", "5" }, /* Assertions. */ { MU, A, 0, 0, "\\b[^A]", "A_B#" },