diff options
author | Jeremy Evans <[email protected]> | 2022-03-24 11:05:12 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2022-03-29 15:29:15 -0700 |
commit | 6d3f447aecfb56f7d3edbdf9cc68e748e150d7d8 (patch) | |
tree | 3e62c844920025bce49f68931980abf3e5cabcdb /regexec.c | |
parent | 173a6b6a802d80b8cf200308fd3653832b700b1c (diff) |
Fix multiplex backreferencs near end of string in regexp match
Idea from Jirka Marsik.
Fixes [Bug #18631]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5710
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1178,11 +1178,13 @@ static int string_cmp_ic(OnigEncoding enc, int case_fold_flag, # define DATA_ENSURE_CHECK1 (s < right_range) # define DATA_ENSURE_CHECK(n) (s + (n) <= right_range) # define DATA_ENSURE(n) if (s + (n) > right_range) goto fail +# define DATA_ENSURE_CONTINUE(n) if (s + (n) > right_range) continue # define ABSENT_END_POS right_range #else # define DATA_ENSURE_CHECK1 (s < end) # define DATA_ENSURE_CHECK(n) (s + (n) <= end) # define DATA_ENSURE(n) if (s + (n) > end) goto fail +# define DATA_ENSURE_CONTINUE(n) if (s + (n) > end) continue # define ABSENT_END_POS end #endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */ @@ -2645,7 +2647,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, ? STACK_AT(mem_end_stk[mem])->u.mem.pstr : (UChar* )((void* )mem_end_stk[mem])); n = pend - pstart; - DATA_ENSURE(n); + DATA_ENSURE_CONTINUE(n); sprev = s; swork = s; STRING_CMP_VALUE(pstart, swork, n, is_fail); @@ -2684,7 +2686,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, ? STACK_AT(mem_end_stk[mem])->u.mem.pstr : (UChar* )((void* )mem_end_stk[mem])); n = pend - pstart; - DATA_ENSURE(n); + DATA_ENSURE_CONTINUE(n); sprev = s; swork = s; STRING_CMP_VALUE_IC(case_fold_flag, pstart, &swork, n, end, is_fail); |