Skip to content

Commit

Permalink
Fix incorrect patch in c130612
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipHazel committed Nov 20, 2023
1 parent 05206d6 commit 7fe586b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2782,6 +2782,7 @@ uint32_t *previous_callout = NULL;
uint32_t *parsed_pattern = cb->parsed_pattern;
uint32_t *parsed_pattern_end = cb->parsed_pattern_end;
uint32_t *this_parsed_item = NULL;
uint32_t *prev_parsed_item = NULL;
uint32_t meta_quantifier = 0;
uint32_t add_after_mark = 0;
uint32_t xoptions = cb->cx->extra_options;
Expand Down Expand Up @@ -2867,11 +2868,10 @@ while (ptr < ptrend)
uint32_t xset, xunset, *xoptset;
uint32_t terminator;
uint32_t prev_meta_quantifier;
uint32_t *prev_parsed_item = this_parsed_item;
BOOL prev_okquantifier;
PCRE2_SPTR tempptr;
PCRE2_SIZE offset;

if (parsed_pattern >= parsed_pattern_end)
{
errorcode = ERR63; /* Internal error (parsed pattern overflow) */
Expand All @@ -2883,10 +2883,17 @@ while (ptr < ptrend)
errorcode = ERR19;
goto FAILED; /* Parentheses too deeply nested */
}

/* Remember where this item started */

this_parsed_item = parsed_pattern;
/* If the last time round this loop something was added, parsed_pattern will
no longer be equal to this_parsed_item. Remember where the previous item
started and reset for the next item. Note that sometimes round the loop,
nothing gets added (e.g. for ignored white space). */

if (this_parsed_item != parsed_pattern)
{
prev_parsed_item = this_parsed_item;
this_parsed_item = parsed_pattern;
}

/* Get next input character, save its position for callout handling. */

Expand Down Expand Up @@ -3440,7 +3447,8 @@ while (ptr < ptrend)

/* ---- Quantifier post-processing ---- */

/* Check that a quantifier is allowed after the previous item. */
/* Check that a quantifier is allowed after the previous item. This
guarantees that there is a previous item. */

CHECK_QUANTIFIER:
if (!prev_okquantifier)
Expand Down
2 changes: 2 additions & 0 deletions testdata/testinput2
Original file line number Diff line number Diff line change
Expand Up @@ -6051,4 +6051,6 @@ a)"xI
# /|a(?0)/endanchored
# aaaa

/A +/extended

# End of testinput2
2 changes: 2 additions & 0 deletions testdata/testoutput2
Original file line number Diff line number Diff line change
Expand Up @@ -17932,6 +17932,8 @@ No match
# /|a(?0)/endanchored
# aaaa

/A +/extended

# End of testinput2
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
Expand Down

0 comments on commit 7fe586b

Please sign in to comment.