diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index cc1ca7925..eb1d83e3b 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -6466,7 +6466,7 @@ for (;; pptr++) /* Now emit the OP_CLASS/OP_NCLASS/OP_XCLASS/OP_ALLANY opcode. */ pptr = PRIV(compile_class_not_nested)(options, xoptions, pptr + 1, - &code, meta == META_CLASS_NOT, + &code, meta == META_CLASS_NOT, FALSE, errorcodeptr, cb, lengthptr); if (pptr == NULL) return 0; PCRE2_ASSERT(*pptr == META_CLASS_END); diff --git a/src/pcre2_compile.h b/src/pcre2_compile.h index 10a6b0901..52f66cd71 100644 --- a/src/pcre2_compile.h +++ b/src/pcre2_compile.h @@ -263,7 +263,7 @@ void PRIV(update_classbits)(uint32_t ptype, uint32_t pdata, BOOL negated, OP_CLASS, OP_NCLASS, OP_XCLASS, or OP_ALLANY into pcode. */ uint32_t *PRIV(compile_class_not_nested)(uint32_t options, uint32_t xoptions, - uint32_t *start_ptr, PCRE2_UCHAR **pcode, BOOL negate_class, + uint32_t *start_ptr, PCRE2_UCHAR **pcode, BOOL negate_class, BOOL always_map, int *errorcodeptr, compile_block *cb, PCRE2_SIZE *lengthptr); /* Compile the META codes in pptr into opcodes written to pcode. The pptr must diff --git a/src/pcre2_compile_class.c b/src/pcre2_compile_class.c index 22692aa09..6edef24a1 100644 --- a/src/pcre2_compile_class.c +++ b/src/pcre2_compile_class.c @@ -1007,7 +1007,7 @@ become a single OP_CLASS OP_NCLASS, OP_XCLASS, or OP_ALLANY. */ uint32_t * PRIV(compile_class_not_nested)(uint32_t options, uint32_t xoptions, - uint32_t *start_ptr, PCRE2_UCHAR **pcode, BOOL negate_class, + uint32_t *start_ptr, PCRE2_UCHAR **pcode, BOOL negate_class, BOOL always_map, int *errorcodeptr, compile_block *cb, PCRE2_SIZE *lengthptr) { uint32_t *pptr = start_ptr; @@ -1637,7 +1637,8 @@ if ((xclass_props & XCLASS_REQUIRED) != 0) /* If the map is required, move up the extra data to make room for it; otherwise just move the code pointer to the end of the extra data. */ - if ((xclass_props & XCLASS_HAS_8BIT_CHARS) != 0) + if ((xclass_props & XCLASS_HAS_8BIT_CHARS) != 0 || + always_map) { *code++ |= XCL_MAP; (void)memmove(code + (32 / sizeof(PCRE2_UCHAR)), code, @@ -2079,7 +2080,7 @@ switch (meta) prev_ptr = ptr; ptr = PRIV(compile_class_not_nested)(options, xoptions, ptr, &code, (meta != META_CLASS_NOT) == negated, - errorcodeptr, cb, lengthptr); + TRUE, errorcodeptr, cb, lengthptr); if (ptr == NULL) return FALSE; /* We must have a 100% guarantee that ptr increases when diff --git a/src/pcre2_xclass.c b/src/pcre2_xclass.c index ab919250f..1300e0511 100644 --- a/src/pcre2_xclass.c +++ b/src/pcre2_xclass.c @@ -79,20 +79,15 @@ const uint8_t *next_char; utf = TRUE; #endif -/* Code points < 256 are matched against a bitmap, if one is present. If no -bitmap is present, then the XCLASS does not match any code points < 256. */ - -if (c < 256) - { - if ((*data & XCL_MAP) != 0) - return (((const uint8_t *)data+1)[c/8] & (1u << (c&7))) != 0; - return FALSE; - } - -/* Skip the bitmap. */ +/* Code points < 256 are matched against a bitmap, if one is present. */ if ((*data++ & XCL_MAP) != 0) + { + if (c < 256) + return (((const uint8_t *)data)[c/8] & (1u << (c&7))) != 0; + /* Skip bitmap. */ data += 32 / sizeof(PCRE2_UCHAR); + } /* Match against the list of Unicode properties. We won't ever encounter XCL_PROP or XCL_NOTPROP when UTF support is not compiled. */