From: K.Kosako Date: Wed, 15 Mar 2017 04:17:56 +0000 (+0900) Subject: PR #51 and small fix X-Git-Tag: v6.2.0^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=684dc149693943a4ea7b4c01c674b151111b957f;p=onig PR #51 and small fix --- diff --git a/src/regexec.c b/src/regexec.c index 42c8f95..35fef11 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -462,6 +462,7 @@ stack_double(int is_alloca, char** arg_alloc_base, unsigned int n; int used; size_t size; + size_t new_size; char* alloc_base; char* new_alloc_base; OnigStackType *stk_base, *stk_end, *stk; @@ -472,10 +473,11 @@ stack_double(int is_alloca, char** arg_alloc_base, stk = *arg_stk; n = stk_end - stk_base; - n *= 2; size = sizeof(OnigStackIndex) * msa->ptr_num + sizeof(OnigStackType) * n; + n *= 2; + new_size = sizeof(OnigStackIndex) * msa->ptr_num + sizeof(OnigStackType) * n; if (is_alloca != 0) { - new_alloc_base = (char* )xmalloc(size); + new_alloc_base = (char* )xmalloc(new_size); if (IS_NULL(new_alloc_base)) { STACK_SAVE; return ONIGERR_MEMORY; @@ -489,7 +491,7 @@ stack_double(int is_alloca, char** arg_alloc_base, else n = MatchStackLimitSize; } - new_alloc_base = (char* )xrealloc(alloc_base, size); + new_alloc_base = (char* )xrealloc(alloc_base, new_size); if (IS_NULL(new_alloc_base)) { STACK_SAVE; return ONIGERR_MEMORY;