From 842e01bf4130d2e472cbf0d75a32b98970e49ce5 Mon Sep 17 00:00:00 2001 From: Wang Renxin Date: Mon, 15 Jan 2018 19:22:45 +0800 Subject: [PATCH] *fixed some issues when invoking a sub routine. --- HISTORY | 4 ++++ core/my_basic.c | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index b606411..19ac4bd 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,7 @@ +Jan. 15 2018 +Fixed a memory leak with invalid invoking +Fixed a wrong invoking of recursive sub routine + Jan. 3 2018 Fixed a parsing bug with unary negative operator diff --git a/core/my_basic.c b/core/my_basic.c index c510e8e..5fd8ac6 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -4456,11 +4456,14 @@ static int _eval_script_routine(mb_interpreter_t* s, _ls_node_t** l, mb_value_t* #ifdef MB_ENABLE_CLASS bool_t pushed_inst = false; _class_t* last_inst = 0; + bool_t same_inst = s->last_routine ? s->last_routine->instance == r->instance : false; +#else /* MB_ENABLE_CLASS */ + bool_t same_inst = true; #endif /* MB_ENABLE_CLASS */ mb_assert(s && l && r); - if(!va && s->last_routine && !s->last_routine->func.basic.parameters && (s->last_routine->name == r->name || !strcmp(s->last_routine->name, r->name))) { + if(!va && s->last_routine && !s->last_routine->func.basic.parameters && same_inst && (s->last_routine->name == r->name || !strcmp(s->last_routine->name, r->name))) { ast = *l; _skip_to(s, &ast, 0, _DT_EOS); if(ast && ((_object_t*)ast->data)->type == _DT_EOS) @@ -9507,6 +9510,7 @@ static _ls_node_t* _search_identifier_accessor(mb_interpreter_t* s, _running_con char acc[_SINGLE_SYMBOL_MAX_LENGTH]; int i = 0; int j = 0; + int nc = 0; #ifdef MB_ENABLE_CLASS _class_t* instance = 0; #else /* MB_ENABLE_CLASS */ @@ -9519,6 +9523,7 @@ static _ls_node_t* _search_identifier_accessor(mb_interpreter_t* s, _running_con acc[j] = n[i]; if(_is_accessor_char(acc[j]) || acc[j] == _ZERO_CHAR) { acc[j] = _ZERO_CHAR; + ++nc; do { #ifdef MB_ENABLE_CLASS if(instance) { @@ -9530,6 +9535,8 @@ static _ls_node_t* _search_identifier_accessor(mb_interpreter_t* s, _running_con } break; + } else if(nc > 1) { + return 0; } #endif /* MB_ENABLE_CLASS */