summaryrefslogtreecommitdiff
path: root/src/regexec.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-04-29 15:21:27 +0200
committerJörg Frings-Fürst <debian@jff.email>2022-04-29 15:21:27 +0200
commita18b0a88c2af4bc0c371f2e76fb3d75e88f1ff77 (patch)
treec42c12a03537b21e5ec847c489529a0733ba8f6b /src/regexec.c
parente179aaa7fd01fa35bb86aab50ff6132bf94533c5 (diff)
parentb221fe9845ea6d4639db16221f6fa8ab2ad11d8e (diff)
Merge branch 'feature/upstream' into develop
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;