fixed the fault in checking the number of arguments for variadic functions in hawk_rtx_evalcall()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ca5ca2c3ce
commit
b6a512f90f
20
lib/run.c
20
lib/run.c
@ -6793,9 +6793,11 @@ hawk_val_t* hawk_rtx_evalcall (
|
||||
|
||||
/* make a new stack frame */
|
||||
stack_req = 4 + call->nargs;
|
||||
if (fun)
|
||||
if (fun && fun->nargs > call->nargs)
|
||||
{
|
||||
HAWK_ASSERT (fun->nargs >= call->nargs); /* the compiler must guarantee this */
|
||||
/* for variadic functions, fun->nargs can be less than call->nargs.
|
||||
* for non-variadic functions, the compiler must guarantee that fun->nargs >= call->nargs
|
||||
* this case can happen for for non-variadic functions only. */
|
||||
stack_req += fun->nargs - call->nargs;
|
||||
}
|
||||
/* if fun is HAWK_NULL, there is no way for this function to know expected argument numbers.
|
||||
@ -7153,25 +7155,11 @@ static hawk_oow_t push_arg_from_nde (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, v
|
||||
break;
|
||||
}
|
||||
|
||||
case 'V':
|
||||
/* the variadic argument marked with ... in the function parameter */
|
||||
if (p->type == HAWK_NDE_LCL)
|
||||
{
|
||||
hawk_nde_var_t* var = (hawk_nde_var_t*)p;
|
||||
v = hawk_rtx_makeintval(rtx, ((hawk_nde_var_t*)p)->id.idxa);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* THIS IS THE RUNTIME ERROR */
|
||||
/* TODO: */
|
||||
}
|
||||
|
||||
case 'x':
|
||||
/* a regular expression is passed to the function as it is */
|
||||
v = eval_expression0(rtx, p);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
normal_arg:
|
||||
v = eval_expression(rtx, p);
|
||||
|
@ -585,7 +585,7 @@ function main()
|
||||
|
||||
|
||||
{
|
||||
@local a, b;
|
||||
@local a, b, f;
|
||||
|
||||
RSTART=99;
|
||||
RLENGTH=99;
|
||||
@ -652,6 +652,12 @@ function main()
|
||||
tap_ensure (test10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 55, @SCRIPTNAME, @SCRIPTLINE);
|
||||
tap_ensure (test11("aa", "bb", "cc"), 0, @SCRIPTNAME, @SCRIPTLINE);
|
||||
tap_ensure (test11("aa", "bb", "cc", "dd"), 1, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
f = test11;
|
||||
tap_ensure (f("aa", "bb", "cc", "dd"), 1, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
f = test10
|
||||
tap_ensure (f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 55, @SCRIPTNAME, @SCRIPTLINE);
|
||||
}
|
||||
tap_end ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user