Skip to content

Commit 994536c

Browse files
author
Zoltan Herczeg
committed
Fixing an issue using empty character sets in jit
1 parent aaa7257 commit 994536c

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/pcre2_jit_compile.c

+16-7
Original file line numberDiff line numberDiff line change
@@ -6186,25 +6186,34 @@ if (max < 1)
61866186
/* Convert last_count to priority. */
61876187
for (i = 0; i < max; i++)
61886188
{
6189-
SLJIT_ASSERT(chars[i].count > 0 && chars[i].last_count <= chars[i].count);
6189+
SLJIT_ASSERT(chars[i].last_count <= chars[i].count);
61906190

6191-
if (chars[i].count == 1)
6191+
switch (chars[i].count)
61926192
{
6193+
case 0:
6194+
chars[i].count = 255;
6195+
chars[i].last_count = 0;
6196+
break;
6197+
6198+
case 1:
61936199
chars[i].last_count = (chars[i].last_count == 1) ? 7 : 5;
61946200
/* Simplifies algorithms later. */
61956201
chars[i].chars[1] = chars[i].chars[0];
6196-
}
6197-
else if (chars[i].count == 2)
6198-
{
6202+
break;
6203+
6204+
case 2:
61996205
SLJIT_ASSERT(chars[i].chars[0] != chars[i].chars[1]);
62006206

62016207
if (is_powerof2(chars[i].chars[0] ^ chars[i].chars[1]))
62026208
chars[i].last_count = (chars[i].last_count == 2) ? 6 : 4;
62036209
else
62046210
chars[i].last_count = (chars[i].last_count == 2) ? 3 : 2;
6205-
}
6206-
else
6211+
break;
6212+
6213+
default:
62076214
chars[i].last_count = (chars[i].count == 255) ? 0 : 1;
6215+
break;
6216+
}
62086217
}
62096218

62106219
#ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD

src/pcre2_jit_test.c

+1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ static struct regression_test_case regression_test_cases[] = {
396396
{ MU, A, 0, 0, "[\\x{10001}-\\x{10fffe}]+", "#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf0\x90\x80\x81\xf4\x8f\xbf\xbe\xf4\x8f\xbf\xbf" },
397397
{ MU, A, 0, 0, "[^\\x{10001}-\\x{10fffe}]+", "\xf0\x90\x80\x81#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf4\x8f\xbf\xbf\xf4\x8f\xbf\xbe" },
398398
{ CMU, A, 0, 0 | F_NOMATCH | F_PROPERTY, "^[\\x{100}-\\x{17f}]", " " },
399+
{ M, A, 0, 0 | F_NOMATCH, "[^\\S\\W]{6}", "abcdefghijk" },
399400

400401
/* Unicode properties. */
401402
{ MUP, A, 0, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },

0 commit comments

Comments
 (0)