aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorK.Kosako <kkosako0@gmail.com>2024-06-20 00:41:50 +0900
committerK.Kosako <kkosako0@gmail.com>2024-06-20 00:41:50 +0900
commitbcfbab2e38956c67029a4743a97644f119dc4be3 (patch)
tree8c883d8b9bbc5d63fad2f2167c8d8819f4c56670
parentc5e9caed544466452c7275bedfa51d2d68b71657 (diff)
downloadoniguruma-bcfbab2e38956c67029a4743a97644f119dc4be3.zip
oniguruma-bcfbab2e38956c67029a4743a97644f119dc4be3.tar.gz
oniguruma-bcfbab2e38956c67029a4743a97644f119dc4be3.tar.bz2
fix #290: retry limit in match == 0 means unlimited
-rw-r--r--src/regexec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/regexec.c b/src/regexec.c
index 3afe724..35a94ad 100644
--- a/src/regexec.c
+++ b/src/regexec.c
@@ -1393,8 +1393,9 @@ static unsigned long RetryLimitInMatch = DEFAULT_RETRY_LIMIT_IN_MATCH;
static unsigned long RetryLimitInSearch = DEFAULT_RETRY_LIMIT_IN_SEARCH;
#define CHECK_RETRY_LIMIT_IN_MATCH do {\
- if (++retry_in_match_counter > retry_limit_in_match) {\
- MATCH_AT_ERROR_RETURN(retry_in_match_counter > msa->retry_limit_in_match ? ONIGERR_RETRY_LIMIT_IN_MATCH_OVER : ONIGERR_RETRY_LIMIT_IN_SEARCH_OVER); \
+ if (++retry_in_match_counter >= retry_limit_in_match && \
+ retry_limit_in_match != 0) {\
+ MATCH_AT_ERROR_RETURN((retry_in_match_counter >= msa->retry_limit_in_match && msa->retry_limit_in_match != 0) ? ONIGERR_RETRY_LIMIT_IN_MATCH_OVER : ONIGERR_RETRY_LIMIT_IN_SEARCH_OVER); \
}\
} while (0)
@@ -3046,7 +3047,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (msa->retry_limit_in_search != 0) {
unsigned long rem = msa->retry_limit_in_search
- msa->retry_limit_in_search_counter;
- if (rem < retry_limit_in_match)
+ if (rem < retry_limit_in_match || retry_limit_in_match == 0)
retry_limit_in_match = rem;
}
#endif