fixed an array access problem by an out-of-range index in eval_indexed()
This commit is contained in:
parent
f860798821
commit
1b7ef41ee4
@ -6918,7 +6918,8 @@ static hawk_val_t* eval_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* var)
|
|||||||
if (idx <= -1) return HAWK_NULL;
|
if (idx <= -1) return HAWK_NULL;
|
||||||
|
|
||||||
arr = ((hawk_val_arr_t*)v)->arr;
|
arr = ((hawk_val_arr_t*)v)->arr;
|
||||||
return HAWK_ARR_SLOT(arr, idx)? ((hawk_val_t*)HAWK_ARR_DPTR(arr, idx)): ((hawk_val_t*)&hawk_val_nil);
|
/* return nil if the index is out of range or the element at the index is not set */
|
||||||
|
return (idx < HAWK_ARR_SIZE(arr) && HAWK_ARR_SLOT(arr, idx))? ((hawk_val_t*)HAWK_ARR_DPTR(arr, idx)): hawk_val_nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user