diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index b7449046a8..f3ea33f782 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -179,6 +179,8 @@ HRESULT create_exec_ctx(IDispatch *this_obj, DispatchEx *var_disp, scope_chain_t if(!ctx) return E_OUTOFMEMORY; + ctx->ref = 1; + IDispatch_AddRef(this_obj); ctx->this_obj = this_obj; diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 3863f7dab3..dac8d3e23b 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -197,9 +197,10 @@ static HRESULT invoke_constructor(FunctionInstance *function, LCID lcid, DISPPAR return hres; hres = invoke_source(function, (IDispatch*)_IDispatchEx_(this_obj), lcid, dp, retv, ei, caller); - jsdisp_release(this_obj); - if(FAILED(hres)) + if(FAILED(hres)) { + jsdisp_release(this_obj); return hres; + } V_VT(retv) = VT_DISPATCH; V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj);