@@ -2782,6 +2782,7 @@ uint32_t *previous_callout = NULL;
27822782uint32_t * parsed_pattern = cb -> parsed_pattern ;
27832783uint32_t * parsed_pattern_end = cb -> parsed_pattern_end ;
27842784uint32_t * this_parsed_item = NULL ;
2785+ uint32_t * prev_parsed_item = NULL ;
27852786uint32_t meta_quantifier = 0 ;
27862787uint32_t add_after_mark = 0 ;
27872788uint32_t xoptions = cb -> cx -> extra_options ;
@@ -2867,11 +2868,10 @@ while (ptr < ptrend)
28672868 uint32_t xset , xunset , * xoptset ;
28682869 uint32_t terminator ;
28692870 uint32_t prev_meta_quantifier ;
2870- uint32_t * prev_parsed_item = this_parsed_item ;
28712871 BOOL prev_okquantifier ;
28722872 PCRE2_SPTR tempptr ;
28732873 PCRE2_SIZE offset ;
2874-
2874+
28752875 if (parsed_pattern >= parsed_pattern_end )
28762876 {
28772877 errorcode = ERR63 ; /* Internal error (parsed pattern overflow) */
@@ -2883,10 +2883,17 @@ while (ptr < ptrend)
28832883 errorcode = ERR19 ;
28842884 goto FAILED ; /* Parentheses too deeply nested */
28852885 }
2886-
2887- /* Remember where this item started */
28882886
2889- this_parsed_item = parsed_pattern ;
2887+ /* If the last time round this loop something was added, parsed_pattern will
2888+ no longer be equal to this_parsed_item. Remember where the previous item
2889+ started and reset for the next item. Note that sometimes round the loop,
2890+ nothing gets added (e.g. for ignored white space). */
2891+
2892+ if (this_parsed_item != parsed_pattern )
2893+ {
2894+ prev_parsed_item = this_parsed_item ;
2895+ this_parsed_item = parsed_pattern ;
2896+ }
28902897
28912898 /* Get next input character, save its position for callout handling. */
28922899
@@ -3440,7 +3447,8 @@ while (ptr < ptrend)
34403447
34413448 /* ---- Quantifier post-processing ---- */
34423449
3443- /* Check that a quantifier is allowed after the previous item. */
3450+ /* Check that a quantifier is allowed after the previous item. This
3451+ guarantees that there is a previous item. */
34443452
34453453 CHECK_QUANTIFIER :
34463454 if (!prev_okquantifier )
0 commit comments