From 40612d55c628cb80dc7cb2b98bad8d8cde9c1f75 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 7 May 2021 18:41:48 +0900 Subject: [PATCH] Fixed shorten-64-to-32 errors when USE_COMBINATION_EXPLOSION_CHECK --- regcomp.c | 2 -- regexec.c | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/regcomp.c b/regcomp.c index 3a438b94c4..44ee0b2e51 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3755,10 +3755,8 @@ setup_comb_exp_check(Node* node, int state, ScanEnv* env) switch (type) { case NT_LIST: { - Node* prev = NULL_NODE; do { r = setup_comb_exp_check(NCAR(node), r, env); - prev = NCAR(node); } while (r >= 0 && IS_NOT_NULL(node = NCDR(node))); } break; diff --git a/regexec.c b/regexec.c index 10ada4d81d..8334b16e96 100644 --- a/regexec.c +++ b/regexec.c @@ -601,7 +601,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, (((s) - str) * num_comb_exp_check + ((snum) - 1)) # define STATE_CHECK_VAL(v,snum) do {\ if (state_check_buff != NULL) {\ - int x = STATE_CHECK_POS(s,snum);\ + ptrdiff_t x = STATE_CHECK_POS(s,snum);\ (v) = state_check_buff[x/8] & (1<<(x%8));\ }\ else (v) = 0;\ @@ -610,7 +610,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, # define ELSE_IF_STATE_CHECK_MARK(stk) \ else if ((stk)->type == STK_STATE_CHECK_MARK) { \ - int x = STATE_CHECK_POS(stk->u.state.pstr, stk->u.state.state_check);\ + ptrdiff_t x = STATE_CHECK_POS(stk->u.state.pstr, stk->u.state.state_check);\ state_check_buff[x/8] |= (1<<(x%8)); \ } @@ -3873,7 +3873,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On MATCH_ARG_INIT(msa, option, region, at, at); #ifdef USE_COMBINATION_EXPLOSION_CHECK { - int offset = at - str; + ptrdiff_t offset = at - str; STATE_CHECK_BUFF_INIT(msa, end - str, offset, reg->num_comb_exp_check); } #endif @@ -4352,7 +4352,7 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end, MATCH_ARG_INIT(msa, option, region, start, global_pos); #ifdef USE_COMBINATION_EXPLOSION_CHECK { - int offset = (MIN(start, range) - str); + ptrdiff_t offset = (MIN(start, range) - str); STATE_CHECK_BUFF_INIT(msa, end - str, offset, reg->num_comb_exp_check); } #endif