diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 9ddfacfb41a..d8ae0fc3132 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1832,7 +1832,8 @@ void release_vbscode(vbscode_t *code) { unsigned i; - list_remove(&code->entry); + if(--code->ref) + return; for(i=0; i < code->bstr_cnt; i++) SysFreeString(code->bstr_pool[i]); @@ -1875,6 +1876,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ret->main_code.type = FUNC_GLOBAL; ret->main_code.code_ctx = ret; + ret->ref = 1; list_init(&ret->entry); return ret; diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index f7890362c64..94daace4fe2 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -223,7 +223,10 @@ static void release_script(script_ctx_t *ctx) if(code->last_class) code->last_class->next = NULL; } else + { + list_remove(&code->entry); release_vbscode(code); + } } while(!list_empty(&ctx->named_items)) { @@ -262,8 +265,12 @@ static void release_script(script_ctx_t *ctx) static void release_code_list(script_ctx_t *ctx) { - while(!list_empty(&ctx->code_list)) - release_vbscode(LIST_ENTRY(list_head(&ctx->code_list), vbscode_t, entry)); + while(!list_empty(&ctx->code_list)) { + vbscode_t *iter = LIST_ENTRY(list_head(&ctx->code_list), vbscode_t, entry); + + list_remove(&iter->entry); + release_vbscode(iter); + } } static void decrease_state(VBScript *This, SCRIPTSTATE state) diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index f4e7bc7b2d4..2f1b61b1abf 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -336,6 +336,7 @@ struct _function_t { struct _vbscode_t { instr_t *instrs; WCHAR *source; + unsigned ref; BOOL option_explicit;