From bcfbab2e38956c67029a4743a97644f119dc4be3 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Thu, 20 Jun 2024 00:41:50 +0900 Subject: fix #290: retry limit in match == 0 means unlimited --- src/regexec.c | 7 ++++--- 1 file 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 -- cgit v1.1