From f1fba035accf63c1f7c9556a48296e957f475d9c Mon Sep 17 00:00:00 2001 From: Wang Renxin Date: Sat, 14 Jul 2018 19:04:49 +0800 Subject: [PATCH] *fixed a multiple disposing bug with upvalues. --- HISTORY | 3 +++ core/my_basic.c | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/HISTORY b/HISTORY index 1ff423d..c73fa94 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +Jul. 14 2018 +Fixed a multiple disposing bug with upvalues + May. 13 2018 Added platform dependent macros for Emscripten diff --git a/core/my_basic.c b/core/my_basic.c index 900b7d6..da1ff4e 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -8915,6 +8915,10 @@ static void _mark_upvalue(mb_interpreter_t* s, _lambda_t* lambda, _object_t* obj running = s->running_context; scp = _search_identifier_in_scope_chain(s, running, n, _PATHING_NORMAL, 0, &found_in_scope); if(scp && found_in_scope) { + _object_t* rot = (_object_t*)scp->data; + rot = _GET_ROUTINE(rot); + if(rot && lambda->scope && lambda->scope->prev != found_in_scope) + return; if(!found_in_scope->refered_lambdas) found_in_scope->refered_lambdas = _ls_create(); if(!_ls_find(found_in_scope->refered_lambdas, lambda, (_ls_compare_t)_ht_cmp_intptr, 0)) @@ -9041,17 +9045,19 @@ static int _fill_with_upvalue(void* data, void* extra, _upvalue_scope_tuple_t* t ast = tuple->lambda->entry; while(ast && ast != tuple->lambda->end->next) { _object_t* aobj = (_object_t*)ast->data; - switch(aobj->type) { - case _DT_VAR: - if(!strcmp(aobj->data.variable->name, ovar->data.variable->name)) { + if(aobj) { + switch(aobj->type) { + case _DT_VAR: + if(!strcmp(aobj->data.variable->name, ovar->data.variable->name)) { #ifdef MB_ENABLE_CLASS - aobj->data.variable->pathing = _PATHING_UPVALUE; + aobj->data.variable->pathing = _PATHING_UPVALUE; #endif /* MB_ENABLE_CLASS */ - } + } - break; - default: /* Do nothing */ - break; + break; + default: /* Do nothing */ + break; + } } ast = ast->next; }