From 25cf18bf40e7983be287174e109a1bc96c7a1029 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Mon, 24 Jun 2024 00:01:41 +0900 Subject: add retry limit counter overflow check in DEBUG mode --- src/regexec.c | 7 +++++++ src/regint.h | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/regexec.c b/src/regexec.c index 35a94ad..ddec265 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -4478,6 +4478,13 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, match_at_end: if (msa->retry_limit_in_search != 0) { +#ifdef ONIG_DEBUG + if (retry_in_match_counter > + ULONG_MAX - msa->retry_limit_in_search_counter) { + fprintf(DBGFP, "retry limit counter overflow: %8lu/%8lu\n", + retry_in_match_counter, msa->retry_limit_in_search_counter); + } +#endif msa->retry_limit_in_search_counter += retry_in_match_counter; } diff --git a/src/regint.h b/src/regint.h index b7a89a6..834a81c 100644 --- a/src/regint.h +++ b/src/regint.h @@ -37,6 +37,7 @@ /* #define ONIG_DEBUG_MATCH_COUNTER */ /* #define ONIG_DEBUG_CALL */ /* #define ONIG_DONT_OPTIMIZE */ +/* #define ONIG_DEBUG */ /* for byte-code statistical data. */ /* #define ONIG_DEBUG_STATISTICS */ @@ -47,10 +48,13 @@ defined(ONIG_DEBUG_STATISTICS) #ifndef ONIG_DEBUG #define ONIG_DEBUG -#define DBGFP stderr #endif #endif +#ifdef ONIG_DEBUG +#define DBGFP stderr +#endif + #ifndef ONIG_DISABLE_DIRECT_THREADING #ifdef __GNUC__ #define USE_GOTO_LABELS_AS_VALUES -- cgit v1.1