@@ -833,6 +833,18 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
833833 case OP_ACCEPT :
834834 case OP_END :
835835
836+ /* Fail if PCRE2_ENDANCHORED is set and the end of the match is not
837+ the end of the subject. After (*ACCEPT) we fail the entire match (at this
838+ position) but backtrack if we've reached the end of the pattern. This
839+ applies whether or not we are in a recursion. */
840+
841+ if (Feptr < mb -> end_subject &&
842+ ((mb -> moptions | mb -> poptions ) & PCRE2_ENDANCHORED ) != 0 )
843+ {
844+ if (Fop == OP_END ) RRETURN (MATCH_NOMATCH );
845+ return MATCH_NOMATCH ; /* (*ACCEPT) */
846+ }
847+
836848 /* Handle end of a recursion. */
837849
838850 if (Fcurrent_recurse != RECURSE_UNSET )
@@ -871,17 +883,6 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
871883 Fstart_match == mb -> start_subject + mb -> start_offset )))
872884 RRETURN (MATCH_NOMATCH );
873885
874- /* Also fail if PCRE2_ENDANCHORED is set and the end of the match is not
875- the end of the subject. After (*ACCEPT) we fail the entire match (at this
876- position) but backtrack on reaching the end of the pattern. */
877-
878- if (Feptr < mb -> end_subject &&
879- ((mb -> moptions | mb -> poptions ) & PCRE2_ENDANCHORED ) != 0 )
880- {
881- if (Fop == OP_END ) RRETURN (MATCH_NOMATCH );
882- return MATCH_NOMATCH ;
883- }
884-
885886 /* We have a successful match of the whole pattern. Record the result and
886887 then do a direct return from the function. If there is space in the offset
887888 vector, set any pairs that follow the highest-numbered captured string but
0 commit comments