summaryrefslogtreecommitdiff
path: root/src/regexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regexec.c')
-rw-r--r--src/regexec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/regexec.c b/src/regexec.c
index a3cf60a..cb8e620 100644
--- a/src/regexec.c
+++ b/src/regexec.c
@@ -2,7 +2,7 @@
regexec.c - Oniguruma (regular expression library)
**********************************************************************/
/*-
- * Copyright (c) 2002-2021 K.Kosako
+ * Copyright (c) 2002-2022 K.Kosako
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -2478,7 +2478,7 @@ static int string_cmp_ic(OnigEncoding enc, int case_fold_flag,
#define ON_STR_BEGIN(s) ((s) == str)
#define ON_STR_END(s) ((s) == end)
#define DATA_ENSURE_CHECK1 (s < right_range)
-#define DATA_ENSURE_CHECK(n) (s + (n) <= right_range)
+#define DATA_ENSURE_CHECK(n) ((n) <= right_range - s)
#define DATA_ENSURE(n) if (right_range - s < (n)) goto fail
#define INIT_RIGHT_RANGE right_range = (UChar* )in_right_range
@@ -3050,6 +3050,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (n > msa->best_len) {
msa->best_len = n;
msa->best_s = (UChar* )sstart;
+ if (s >= in_right_range) {
+ best_len = msa->best_len; /* end of find */
+ }
}
else {
if (s >= in_right_range && msa->best_s == sstart) {
@@ -3858,7 +3861,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
pend = STACK_MEM_END(reg, mem);
n = (int )(pend - pstart);
if (n != 0) {
- DATA_ENSURE(n);
+ if (! DATA_ENSURE_CHECK(n)) continue;
swork = s;
STRING_CMP_VALUE(swork, pstart, n, is_fail);
if (is_fail) continue;
@@ -3887,7 +3890,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
pend = STACK_MEM_END(reg, mem);
n = (int )(pend - pstart);
if (n != 0) {
- DATA_ENSURE(n);
+ if (! DATA_ENSURE_CHECK(n)) continue;
swork = s;
STRING_CMP_VALUE_IC(case_fold_flag, pstart, &swork, n, is_fail);
if (is_fail) continue;