summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-09-04 16:01:43 +0900
committernagachika <nagachika@ruby-lang.org>2022-09-04 16:01:43 +0900
commit6b8bf6ba5d1893b3c933c2de3ada1eb59a94b644 (patch)
tree7c58c6855ac4b9055ed9223bcbea7934b0758f57 /regexec.c
parent1cfc139f6d0cb80d6024b0c416976194929417cf (diff)
merge revision(s) 6d3f447aecfb56f7d3edbdf9cc68e748e150d7d8: [Backport #18631]
Fix multiplex backreferencs near end of string in regexp match Idea from Jirka Marsik. Fixes [Bug #18631] --- regexec.c | 6 ++++-- test/ruby/test_regexp.rb | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-)
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/regexec.c b/regexec.c
index 8334b16e96..a7b948e99c 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1176,11 +1176,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 */
@@ -2643,7 +2645,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);
@@ -2682,7 +2684,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);