jscript: Fix some refcount leaks.

In particular, most leak when jsdisp->ctx is not the current ctx.

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 2021-10-25 16:30:25 +03:00 committed by Alexandre Julliard
parent 7ba8943e72
commit 4e5c4758ff
1 changed files with 14 additions and 1 deletions

View File

@ -2028,6 +2028,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns
if(jsdisp && jsdisp->ctx == ctx) {
if(flags & DISPATCH_PROPERTYPUT) {
FIXME("disp_call(propput) on builtin object\n");
jsdisp_release(jsdisp);
return E_FAIL;
}
@ -2037,6 +2038,8 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns
jsdisp_release(jsdisp);
return hres;
}
if(jsdisp)
jsdisp_release(jsdisp);
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
if(ret && argc)
@ -2106,6 +2109,8 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
jsdisp_release(jsdisp);
return hres;
}
if(jsdisp)
jsdisp_release(jsdisp);
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
if(r && argc && flags == DISPATCH_METHOD)
@ -2205,6 +2210,8 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val)
VARIANT var;
DISPPARAMS dp = {&var, &dispid, 1, 1};
if(jsdisp)
jsdisp_release(jsdisp);
hres = jsval_to_variant(val, &var);
if(FAILED(hres))
return hres;
@ -2230,6 +2237,8 @@ HRESULT disp_propput_name(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name,
BSTR str;
DISPID id;
if(jsdisp)
jsdisp_release(jsdisp);
if(!(str = SysAllocString(name)))
return E_OUTOFMEMORY;
@ -2248,7 +2257,9 @@ HRESULT disp_propput_name(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name,
return disp_propput(ctx, disp, id, val);
}
return jsdisp_propput_name(jsdisp, name, val);
hres = jsdisp_propput_name(jsdisp, name, val);
jsdisp_release(jsdisp);
return hres;
}
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
@ -2312,6 +2323,8 @@ HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val
jsdisp_release(jsdisp);
return hres;
}
if(jsdisp)
jsdisp_release(jsdisp);
V_VT(&var) = VT_EMPTY;
hres = disp_invoke(ctx, disp, id, INVOKE_PROPERTYGET, &dp, &var);