*fixed a cannot RETURN bug from a FOR loop in a sub routine; *fixed a memory leak with referenced data in a variable argument list.

This commit is contained in:
paladin-t 2016-03-16 12:45:41 +08:00
parent dca1299260
commit b7c0a68350
3 changed files with 28 additions and 9 deletions

10
HISTORY
View File

@ -1,3 +1,7 @@
Mar. 16 2016
Fixed a cannot RETURN bug from a FOR loop in a sub routine
Fixed a memory leak with referenced data in a variable argument list
Mar. 15 2016 Mar. 15 2016
Improved error promption of array manipulation Improved error promption of array manipulation
@ -119,7 +123,7 @@ Added an mb_gc function
Added a SET_IMPORTING_DIRS statement to the shell Added a SET_IMPORTING_DIRS statement to the shell
Added friendly error promption when memory overflow Added friendly error promption when memory overflow
Added source file information to stepped handler Added source file information to stepped handler
Fixed a wrong argument processing bug with variable arguments Fixed a wrong argument processing bug with a variable argument list
Fixed a wrong hash bug with string object Fixed a wrong hash bug with string object
Fixed a memory corruption bug with importing directory setting Fixed a memory corruption bug with importing directory setting
Optimized cached list accessing Optimized cached list accessing
@ -150,10 +154,10 @@ Jan. 20 2016
Fixed an unknown type handling bug Fixed an unknown type handling bug
Jan. 19 2016 Jan. 19 2016
Added support to apply the LEN statement to variable arguments as LEN(...) Added support to apply the LEN statement to a variable argument list as LEN(...)
Jan. 18 2016 Jan. 18 2016
Added variable arguments support Added a variable argument list support
Added a NOW statement to the shell Added a NOW statement to the shell
Improved shell implementation code Improved shell implementation code

View File

@ -1659,6 +1659,7 @@ static int _create_internal_object_from_public_value(mb_value_t* pbl, _object_t*
static int _compare_public_value_and_internal_object(mb_value_t* pbl, _object_t* itn); static int _compare_public_value_and_internal_object(mb_value_t* pbl, _object_t* itn);
static void _try_clear_intermediate_value(void* data, void* extra, mb_interpreter_t* s); static void _try_clear_intermediate_value(void* data, void* extra, mb_interpreter_t* s);
static void _remove_if_exist(void* data, void* extra, _ls_node_t* ls); static void _remove_if_exist(void* data, void* extra, _ls_node_t* ls);
static void _destroy_var_arg(void* data, void* extra, _gc_t* gc);
static void _destroy_edge_objects(mb_interpreter_t* s); static void _destroy_edge_objects(mb_interpreter_t* s);
static void _mark_edge_destroy_string(mb_interpreter_t* s, char* ch); static void _mark_edge_destroy_string(mb_interpreter_t* s, char* ch);
static void _destroy_lazy_objects(mb_interpreter_t* s); static void _destroy_lazy_objects(mb_interpreter_t* s);
@ -3668,7 +3669,7 @@ _exit:
} }
static _ls_node_t* _push_var_args(mb_interpreter_t* s) { static _ls_node_t* _push_var_args(mb_interpreter_t* s) {
/* Push current variable arguments list */ /* Push current variable argument list */
_ls_node_t* result = s->var_args; _ls_node_t* result = s->var_args;
s->var_args = 0; s->var_args = 0;
@ -3677,12 +3678,12 @@ static _ls_node_t* _push_var_args(mb_interpreter_t* s) {
} }
static void _pop_var_args(mb_interpreter_t* s, _ls_node_t* last_var_args) { static void _pop_var_args(mb_interpreter_t* s, _ls_node_t* last_var_args) {
/* Pop current variable arguments list */ /* Pop current variable argument list */
_ls_node_t* var_args = s->var_args; _ls_node_t* var_args = s->var_args;
s->var_args = last_var_args; s->var_args = last_var_args;
if(var_args) { if(var_args) {
_ls_foreach(var_args, _destroy_object_capsule_only); _LS_FOREACH(var_args, _do_nothing_on_object, _destroy_var_arg, &s->gc);
_ls_destroy(var_args); _ls_destroy(var_args);
} }
} }
@ -9024,6 +9025,18 @@ static void _remove_if_exist(void* data, void* extra, _ls_node_t* ls) {
_ls_try_remove(ls, obj, _ls_cmp_data, 0); _ls_try_remove(ls, obj, _ls_cmp_data, 0);
} }
static void _destroy_var_arg(void* data, void* extra, _gc_t* gc) {
/* Destroy an object in variable argument list */
_object_t* obj = 0;
mb_unrefvar(extra);
mb_assert(data);
obj = (_object_t*)data;
_ADDGC(obj, gc);
safe_free(obj);
}
static void _destroy_edge_objects(mb_interpreter_t* s) { static void _destroy_edge_objects(mb_interpreter_t* s) {
/* Destroy edge destroying objects */ /* Destroy edge destroying objects */
mb_assert(s); mb_assert(s);
@ -9492,7 +9505,9 @@ static int _common_keep_looping(mb_interpreter_t* s, _ls_node_t** l, _var_t* var
_skip_to(s, &ast, 0, _DT_EOS); _skip_to(s, &ast, 0, _DT_EOS);
goto _exit; goto _exit;
} else if(result != MB_FUNC_OK && result != MB_SUB_RETURN) { /* Normally */ } else if(result == MB_SUB_RETURN) { /* RETURN */
goto _exit;
} else if(result != MB_FUNC_OK) { /* Normally */
goto _exit; goto _exit;
} }
@ -9584,7 +9599,7 @@ _to:
result = MB_FUNC_OK; result = MB_FUNC_OK;
goto _exit; goto _exit;
} else if(result != MB_FUNC_OK && result != MB_SUB_RETURN) { } else if(result != MB_FUNC_OK || result == MB_SUB_RETURN) {
goto _exit; goto _exit;
} }
@ -9681,7 +9696,7 @@ _to:
result = MB_FUNC_OK; result = MB_FUNC_OK;
goto _exit; goto _exit;
} else if(result != MB_FUNC_OK && result != MB_SUB_RETURN) { } else if(result != MB_FUNC_OK || result == MB_SUB_RETURN) {
goto _exit; goto _exit;
} }

Binary file not shown.