@@ -6224,39 +6224,29 @@ for (;; pptr++)
62246224 too, we use a special-cased encoding of OP_ALLANY. */
62256225
62266226 if (op_info .op_single_type == ECL_ANY && allbitsone )
6227- {
6228- if (lengthptr == NULL ) * code ++ = OP_ALLANY ;
6229- }
6227+ * code ++ = OP_ALLANY ;
62306228
62316229 /* If the high bits are all matched / all not-matched, then we emit an
62326230 OP_NCLASS/OP_CLASS respectively. */
62336231
62346232 else if (op_info .op_single_type == ECL_ANY ||
62356233 op_info .op_single_type == ECL_NONE )
62366234 {
6237- PCRE2_SIZE required_len = 1 + (32 / sizeof (PCRE2_UCHAR ));
6238-
6239- if (lengthptr != NULL )
6240- {
6241- /* Don't unconditionally request 32 more bytes - we probably already
6242- reserved that much space inside compile_class_nested(). */
6243- if (required_len > (* lengthptr - previous_length ))
6244- {
6245- * lengthptr = previous_length + required_len ;
6246- }
6247- }
6248- else
6249- {
6250- * code ++ = (op_info .op_single_type == ECL_ANY )? OP_NCLASS : OP_CLASS ;
6251- memcpy (code , op_info .bits .classbits , 32 );
6252- code += 32 / sizeof (PCRE2_UCHAR );
6253- }
6235+ * code ++ = (op_info .op_single_type == ECL_ANY )? OP_NCLASS : OP_CLASS ;
6236+ memcpy (code , op_info .bits .classbits , 32 );
6237+ code += 32 / sizeof (PCRE2_UCHAR );
62546238 }
62556239
62566240 /* Otherwise, we have an ECL_XCLASS, so we have the OP_XCLASS data
62576241 there, but, we pulled out its bitmap into op_info, so now we have to
62586242 put that back into the OP_XCLASS. */
62596243
6244+ #ifndef SUPPORT_WIDE_CHARS
6245+ else
6246+ {
6247+ PCRE2_DEBUG_UNREACHABLE ();
6248+ }
6249+ #else
62606250 else
62616251 {
62626252 BOOL need_map ;
@@ -6269,10 +6259,22 @@ for (;; pptr++)
62696259
62706260 if (lengthptr != NULL )
62716261 {
6262+ /* Don't unconditionally request all the space we need - we may
6263+ already have asked for more during processing of the ECLASS. */
62726264 if (required_len > (* lengthptr - previous_length ))
62736265 {
62746266 * lengthptr = previous_length + required_len ;
62756267 }
6268+
6269+ /* The code we write out here won't be ignored, even during the
6270+ (lengthptr != NULL) phase, because if there's a following quantifier
6271+ it will peek backwards. So we do have to write out a (truncated)
6272+ OP_XCLASS, even on this branch. */
6273+ * lengthptr -= 1 + LINK_SIZE + 1 ;
6274+ * code ++ = OP_XCLASS ;
6275+ PUT (code , 0 , 1 + LINK_SIZE + 1 );
6276+ code += LINK_SIZE ;
6277+ * code ++ = 0 ;
62766278 }
62776279 else
62786280 {
@@ -6307,6 +6309,7 @@ for (;; pptr++)
63076309 code += rest_len ;
63086310 }
63096311 }
6312+ #endif /* SUPPORT_WIDE_CHARS */
63106313 }
63116314
63126315 /* Otherwise, we're going to keep the OP_ECLASS. However, again we need
0 commit comments