Skip to content

Commit

Permalink
Fix handling of reg->dmin in Regex matching
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-peka authored and nurse committed Apr 22, 2024
1 parent c38fc1b commit dde9921
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -4900,12 +4900,17 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
UChar* range, UChar** low, UChar** high, UChar** low_prev)
{
UChar *p, *pprev = (UChar* )NULL;
size_t input_len = end - str;

#ifdef ONIG_DEBUG_SEARCH
fprintf(stderr, "forward_search_range: str: %"PRIuPTR" (%p), end: %"PRIuPTR" (%p), s: %"PRIuPTR" (%p), range: %"PRIuPTR" (%p)\n",
(uintptr_t )str, str, (uintptr_t )end, end, (uintptr_t )s, s, (uintptr_t )range, range);
#endif

if (reg->dmin > input_len) {
return 0;
}

p = s;
if (reg->dmin > 0) {
if (ONIGENC_IS_SINGLEBYTE(reg->enc)) {
Expand Down Expand Up @@ -5042,6 +5047,11 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
UChar** low, UChar** high)
{
UChar *p;
size_t input_len = end - str;

if (reg->dmin > input_len) {
return 0;
}

range += reg->dmin;
p = s;
Expand Down

0 comments on commit dde9921

Please sign in to comment.