vbscript: Reference count the vbscode_t.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2019-12-06 13:45:28 +01:00 committed by Alexandre Julliard
parent cdc5ac52fc
commit 6c2f99c84e
3 changed files with 13 additions and 3 deletions

View File

@ -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;

View File

@ -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)

View File

@ -336,6 +336,7 @@ struct _function_t {
struct _vbscode_t {
instr_t *instrs;
WCHAR *source;
unsigned ref;
BOOL option_explicit;