Skip to content

Commit 7fe586b

Browse files
committed
Fix incorrect patch in c130612
1 parent 05206d6 commit 7fe586b

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/pcre2_compile.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,7 @@ uint32_t *previous_callout = NULL;
27822782
uint32_t *parsed_pattern = cb->parsed_pattern;
27832783
uint32_t *parsed_pattern_end = cb->parsed_pattern_end;
27842784
uint32_t *this_parsed_item = NULL;
2785+
uint32_t *prev_parsed_item = NULL;
27852786
uint32_t meta_quantifier = 0;
27862787
uint32_t add_after_mark = 0;
27872788
uint32_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)

testdata/testinput2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6051,4 +6051,6 @@ a)"xI
60516051
# /|a(?0)/endanchored
60526052
# aaaa
60536053

6054+
/A +/extended
6055+
60546056
# End of testinput2

testdata/testoutput2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17932,6 +17932,8 @@ No match
1793217932
# /|a(?0)/endanchored
1793317933
# aaaa
1793417934

17935+
/A +/extended
17936+
1793517937
# End of testinput2
1793617938
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
1793717939
Error -62: bad serialized data

0 commit comments

Comments
 (0)