From cef14ac3380ee30e04eb3f77f151d0c28f32eb97 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 18 Oct 2019 16:20:40 +0200 Subject: [PATCH] vbscript: Move init_global call to CreateInstance. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/vbscript/vbscript.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index 8b81b7a5e31..56c53b40150 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -128,18 +128,6 @@ IDispatch *lookup_named_item(script_ctx_t *ctx, const WCHAR *name, unsigned flag return NULL; } -static HRESULT set_ctx_site(VBScript *This) -{ - HRESULT hres; - - hres = init_global(This->ctx); - if(FAILED(hres)) - return hres; - - change_state(This, SCRIPTSTATE_INITIALIZED); - return S_OK; -} - static void release_script(script_ctx_t *ctx) { class_desc_t *class_desc; @@ -434,7 +422,9 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript if(hres == S_OK) This->ctx->lcid = lcid; - return This->is_initialized ? set_ctx_site(This) : S_OK; + if(This->is_initialized) + change_state(This, SCRIPTSTATE_INITIALIZED); + return S_OK; } static HRESULT WINAPI VBScript_GetScriptSite(IActiveScript *iface, REFIID riid, @@ -748,7 +738,9 @@ static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface) return E_UNEXPECTED; This->is_initialized = TRUE; - return This->ctx->site ? set_ctx_site(This) : S_OK; + if(This->ctx->site) + change_state(This, SCRIPTSTATE_INITIALIZED); + return S_OK; } static HRESULT WINAPI VBScriptParse_AddScriptlet(IActiveScriptParse *iface, @@ -968,6 +960,12 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pU list_init(&ctx->code_list); list_init(&ctx->named_items); + hres = init_global(ctx); + if(FAILED(hres)) { + IActiveScript_Release(&ret->IActiveScript_iface); + return hres; + } + hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv); IActiveScript_Release(&ret->IActiveScript_iface); return hres;