diff --git a/src/pcre2_intmodedep.h b/src/pcre2_intmodedep.h index 5e7e10d2a..423764d2d 100644 --- a/src/pcre2_intmodedep.h +++ b/src/pcre2_intmodedep.h @@ -880,7 +880,8 @@ typedef struct match_block { PCRE2_SPTR start_code; /* For use when recursing */ PCRE2_SPTR start_subject; /* Start of the subject string */ PCRE2_SPTR check_subject; /* Where UTF-checked from */ - PCRE2_SPTR end_subject; /* End of the subject string */ + PCRE2_SPTR end_subject; /* Usable end of the subject string */ + PCRE2_SPTR true_end_subject; /* Actual end of the subject string */ PCRE2_SPTR end_match_ptr; /* Subject position at end match */ PCRE2_SPTR start_used_ptr; /* Earliest consulted character */ PCRE2_SPTR last_used_ptr; /* Latest consulted character */ diff --git a/src/pcre2_match.c b/src/pcre2_match.c index ea0397655..c5e84cea3 100644 --- a/src/pcre2_match.c +++ b/src/pcre2_match.c @@ -6076,12 +6076,10 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode, if ((mb->poptions & PCRE2_DOLLAR_ENDONLY) == 0) goto ASSERT_NL_OR_EOS; /* Fall through */ - /* Unconditional end of subject assertion (\z). We must check NOTEOL - because it gets set for invalid UTF fragments. */ + /* Unconditional end of subject assertion (\z). */ case OP_EOD: - if (Feptr < mb->end_subject || (mb->moptions & PCRE2_NOTEOL) != 0) - RRETURN(MATCH_NOMATCH); + if (Feptr < mb->true_end_subject) RRETURN(MATCH_NOMATCH); if (mb->partial != 0) { mb->hitend = TRUE; @@ -6891,6 +6889,7 @@ mb->callout_data = mcontext->callout_data; mb->start_subject = subject; mb->start_offset = start_offset; mb->end_subject = end_subject; +mb->true_end_subject = true_end_subject; mb->hasthen = (re->flags & PCRE2_HASTHEN) != 0; mb->allowemptypartial = (re->max_lookbehind > 0) || (re->flags & PCRE2_MATCH_EMPTY) != 0; diff --git a/testdata/testinput2 b/testdata/testinput2 index 0e24e78ed..b874f20c9 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -6055,4 +6055,8 @@ a)"xI /(*ACCEPT)+/B,auto_callout +/a\z/ + a + a\=noteol + # End of testinput2 diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 68800fb43..c1bc0e642 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -17946,6 +17946,12 @@ No match End ------------------------------------------------------------------ +/a\z/ + a + 0: a + a\=noteol + 0: a + # End of testinput2 Error -70: PCRE2_ERROR_BADDATA (unknown error number) Error -62: bad serialized data