*improved stability for sub routine.

This commit is contained in:
paladin-t 2015-11-30 13:40:12 +08:00
parent 37e633e907
commit 2a4d8d40cb
2 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,6 @@
Nov. 30 2015
Improved stability for sub routine
Nov. 26 2015 Nov. 26 2015
Raised error for invalid routine usage Raised error for invalid routine usage
Fixed a memory corruption bug when met an invalid routine usage Fixed a memory corruption bug when met an invalid routine usage

View File

@ -81,7 +81,7 @@ extern "C" {
/** Macros */ /** Macros */
#define _VER_MAJOR 1 #define _VER_MAJOR 1
#define _VER_MINOR 1 #define _VER_MINOR 1
#define _VER_REVISION 99 #define _VER_REVISION 100
#define _VER_SUFFIX #define _VER_SUFFIX
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION)) #define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
#define _STRINGIZE(A) _MAKE_STRINGIZE(A) #define _STRINGIZE(A) _MAKE_STRINGIZE(A)
@ -2867,6 +2867,9 @@ int _eval_routine(mb_interpreter_t* s, _ls_node_t** l, mb_value_t* va, unsigned
running = _push_scope(s, running); running = _push_scope(s, running);
*l = r->entry; *l = r->entry;
if(!(*l)) {
_handle_error_on_obj(s, SE_RN_INVALID_ROUTINE, 0, DON(ast), MB_FUNC_ERR, _exit, result);
}
do { do {
result = _execute_statement(s, l); result = _execute_statement(s, l);
@ -5547,8 +5550,10 @@ int _dispose_object(_object_t* obj) {
case _DT_ROUTINE: case _DT_ROUTINE:
if(!obj->ref) { if(!obj->ref) {
safe_free(obj->data.routine->name); safe_free(obj->data.routine->name);
_ht_foreach(obj->data.routine->scope->var_dict, _destroy_object); if(obj->data.routine->scope->var_dict) {
_ht_destroy(obj->data.routine->scope->var_dict); _ht_foreach(obj->data.routine->scope->var_dict, _destroy_object);
_ht_destroy(obj->data.routine->scope->var_dict);
}
safe_free(obj->data.routine->scope); safe_free(obj->data.routine->scope);
if(obj->data.routine->parameters) if(obj->data.routine->parameters)
_ls_destroy(obj->data.routine->parameters); _ls_destroy(obj->data.routine->parameters);