Skip to content

Commit

Permalink
add retry limit counter overflow check in DEBUG mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kkos committed Jun 23, 2024
1 parent bcfbab2 commit 25cf18b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion src/regint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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
Expand Down

0 comments on commit 25cf18b

Please sign in to comment.