fixed a length calculation bug in fnc_split()

This commit is contained in:
hyung-hwan 2020-11-13 17:44:44 +00:00
parent daf7377403
commit cfa140a925
2 changed files with 4 additions and 6 deletions

View File

@ -797,7 +797,7 @@ static int fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, int use_array)
hawk_ooch_t* fs_free = HAWK_NULL; hawk_ooch_t* fs_free = HAWK_NULL;
hawk_ooch_t* p; hawk_ooch_t* p;
hawk_oow_t str_left, org_len; hawk_oow_t org_len;
hawk_tre_t* fs_rex = HAWK_NULL; hawk_tre_t* fs_rex = HAWK_NULL;
hawk_tre_t* fs_rex_free = HAWK_NULL; hawk_tre_t* fs_rex_free = HAWK_NULL;
@ -887,8 +887,7 @@ static int fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, int use_array)
if (HAWK_UNLIKELY(x <= -1)) goto oops; if (HAWK_UNLIKELY(x <= -1)) goto oops;
/* fill the map with actual values */ /* fill the map with actual values */
p = str.ptr; str_left = str.len; org_len = str.len; p = str.ptr; org_len = str.len; nflds = 0;
nflds = 0;
while (p) while (p)
{ {
@ -954,9 +953,9 @@ static int fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, int use_array)
} }
if (byte_str) if (byte_str)
str.len = str_left - ((p - str.ptr) * HAWK_SIZEOF_OOCH_T); str.len = org_len - ((hawk_bch_t*)p - (hawk_bch_t*)str.ptr);
else else
str.len = str_left - (p - str.ptr); str.len = org_len - (p - str.ptr);
} }
if (do_fld) hawk_rtx_freemem (rtx, str.ptr); if (do_fld) hawk_rtx_freemem (rtx, str.ptr);

View File

@ -2063,7 +2063,6 @@ static int run_pblock (hawk_rtx_t* rtx, hawk_chain_t* cha, hawk_oow_t bno)
static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde)
{ {
hawk_nde_t* p; hawk_nde_t* p;
hawk_oow_t nlcls;
hawk_oow_t saved_stack_top; hawk_oow_t saved_stack_top;
int n = 0; int n = 0;