diff --git a/HISTORY b/HISTORY index 5846a22..74bbe77 100755 --- a/HISTORY +++ b/HISTORY @@ -3,6 +3,7 @@ Added an mb_gc function Added a SET_IMPORTING_DIRS statement to the shell Added friendly error promption when memory overflow Added source file information to stepped handler +Fixed a wrong argument processing bug with variable arguments Fixed a memory corruption bug with importing directory setting Optimized cached list accessing diff --git a/core/my_basic.c b/core/my_basic.c index 0a10645..157af20 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -3468,6 +3468,7 @@ int _pop_arg(mb_interpreter_t* s, _ls_node_t** l, mb_value_t* va, unsigned ca, u int _proc_args(mb_interpreter_t* s, _ls_node_t** l, _running_context_t* running, mb_value_t* va, unsigned ca, _routine_t* r, mb_has_routine_arg_func_t has_arg, mb_pop_routine_arg_func_t pop_arg, bool_t proc_ref, _ls_node_t* args) { /* Process arguments of a routine */ int result = MB_FUNC_OK; + _ls_node_t* ast = 0; _ls_node_t* parameters = 0; mb_value_t arg; _ls_node_t* pars = 0; @@ -3519,6 +3520,7 @@ int _proc_args(mb_interpreter_t* s, _ls_node_t** l, _running_context_t* running, if(args && _ls_empty(args)) break; } + if(_IS_VAR_ARGS(var)) { if(has_arg && !var_args && _IS_VAR_ARGS(var)) var_args = s->var_args = _ls_create(); @@ -3538,9 +3540,11 @@ int _proc_args(mb_interpreter_t* s, _ls_node_t** l, _running_context_t* running, break; } } - if(_IS_VAR_ARGS(var)) { - if(args) { - _ls_node_t* ast = *l; + + ast = *l; + if(ast) { + _object_t* obj = (_object_t*)ast->data; + if(obj && _IS_FUNC(obj, _core_args)) { if(ast) ast = ast->next; *l = ast; } diff --git a/output/my_basic.exe b/output/my_basic.exe index 6756c68..71a430d 100755 Binary files a/output/my_basic.exe and b/output/my_basic.exe differ diff --git a/shell/main.c b/shell/main.c index a2dac22..8df7a10 100755 --- a/shell/main.c +++ b/shell/main.c @@ -657,6 +657,8 @@ static int _new_program(void) { result = mb_reset(&bas, false); + mb_gc(bas, 0); + _tidy_mem_pool(true); return result;