Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
This is needed since put_Language not only calls Close but also the detached modules return E_FAIL since they are orphaned.
dlls/msscript.ocx/msscript.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index df63220..90524a5 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -575,6 +575,17 @@ static void detach_script_host(ScriptHost *host) host->script = NULL; }
+static void detach_module(ScriptModule *module) +{ + ScriptHost *host = module->host; + + if (host) { + module->host = NULL; + detach_script_host(host); + IActiveScriptSite_Release(&host->IActiveScriptSite_iface); + } +} + static HRESULT WINAPI ScriptModule_QueryInterface(IScriptModule *iface, REFIID riid, void **ppv) { ScriptModule *This = impl_from_IScriptModule(iface); @@ -614,8 +625,7 @@ static ULONG WINAPI ScriptModule_Release(IScriptModule *iface)
if (!ref) { - detach_script_host(This->host); - IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); + detach_module(This); heap_free(This); }
@@ -776,12 +786,14 @@ static ScriptModule *create_module(ScriptHost *host) return module; }
-static void release_modules(ScriptControl *control) +static void release_modules(ScriptControl *control, BOOL force_detach) { - unsigned int i; + unsigned int i, module_count = control->host->module_count;
- for (i = 0; i < control->host->module_count; i++) + for (i = 0; i < module_count; i++) { + if (force_detach) detach_module(control->modules[i]); IScriptModule_Release(&control->modules[i]->IScriptModule_iface); + }
heap_free(control->modules); } @@ -1080,7 +1092,7 @@ static ULONG WINAPI ScriptControl_Release(IScriptControl *iface) IOleClientSite_Release(This->site); if (This->host) { - release_modules(This); + release_modules(This, FALSE); IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); } heap_free(This); @@ -1181,7 +1193,7 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan return CTL_E_INVALIDPROPERTYVALUE;
if (This->host) { - release_modules(This); + release_modules(This, TRUE); IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); This->host = NULL; }