From b4e89eec1729d325bd6ff0708fdba63dbd99ac84 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 28 Feb 2020 17:26:21 +0100 Subject: [PATCH] vbscript: Lookup host global object in interp_me instead of storing it in script context. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inspired by patch by Gabriel Ivăncescu. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/vbscript/interp.c | 19 +++++++++++++------ dlls/vbscript/vbscript.c | 10 ---------- dlls/vbscript/vbscript.h | 2 -- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 27a4aee9bdb..d2e1d2a63fa 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1524,16 +1524,23 @@ static HRESULT interp_me(exec_ctx_t *ctx) TRACE("\n"); - if(ctx->vbthis) + if(ctx->vbthis) { disp = (IDispatch*)&ctx->vbthis->IDispatchEx_iface; - else if(ctx->code->named_item) + }else if(ctx->code->named_item) { disp = (ctx->code->named_item->flags & SCRIPTITEM_CODEONLY) ? (IDispatch*)&ctx->code->named_item->script_obj->IDispatchEx_iface : ctx->code->named_item->disp; - else if(ctx->script->host_global) - disp = ctx->script->host_global; - else - disp = (IDispatch*)&ctx->script->script_obj->IDispatchEx_iface; + }else { + named_item_t *item; + disp = NULL; + LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) { + if(!(item->flags & SCRIPTITEM_GLOBALMEMBERS)) continue; + disp = item->disp; + break; + } + if(!disp) + disp = (IDispatch*)&ctx->script->script_obj->IDispatchEx_iface; + } IDispatch_AddRef(disp); V_VT(&v) = VT_DISPATCH; diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index 27985bfc530..ea80911f10d 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -283,11 +283,6 @@ static void release_script(script_ctx_t *ctx) release_named_item(iter); } - if(ctx->host_global) { - IDispatch_Release(ctx->host_global); - ctx->host_global = NULL; - } - if(ctx->secmgr) { IInternetHostSecurityManager_Release(ctx->secmgr); ctx->secmgr = NULL; @@ -675,11 +670,6 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr WARN("object does not implement IDispatch\n"); return hres; } - - if(This->ctx->host_global) - IDispatch_Release(This->ctx->host_global); - IDispatch_AddRef(disp); - This->ctx->host_global = disp; } item = heap_alloc(sizeof(*item)); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 5860863a0ce..27ddae39791 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -186,8 +186,6 @@ struct _script_ctx_t { IInternetHostSecurityManager *secmgr; DWORD safeopt; - IDispatch *host_global; - ScriptDisp *script_obj; BuiltinDisp *global_obj;