vbscript: Allow arbitrary number of arguments in builtin functions.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-11-04 17:37:57 +01:00 committed by Alexandre Julliard
parent 52bbac0a36
commit 2dceea6f35
2 changed files with 18 additions and 3 deletions

View File

@ -172,8 +172,9 @@ static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, L
{
BuiltinDisp *This = impl_from_IDispatch(iface);
const builtin_prop_t *prop;
VARIANT args[8];
VARIANT args_buf[8], *args;
unsigned argn, i;
HRESULT hres;
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, id, debugstr_guid(riid), lcid, flags, dp, res, ei, err);
@ -248,7 +249,13 @@ static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, L
return MAKE_VBSERROR(VBSE_FUNC_ARITY_MISMATCH);
}
assert(argn < ARRAY_SIZE(args));
if(argn <= ARRAY_SIZE(args_buf)) {
args = args_buf;
}else {
args = heap_alloc(argn * sizeof(*args));
if(!args)
return E_OUTOFMEMORY;
}
for(i=0; i < argn; i++) {
if(V_VT(dp->rgvarg+dp->cArgs-i-1) == (VT_BYREF|VT_VARIANT))
@ -257,7 +264,10 @@ static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, L
args[i] = dp->rgvarg[dp->cArgs-i-1];
}
return prop->proc(This, args, dp->cArgs, res);
hres = prop->proc(This, args, dp->cArgs, res);
if(args != args_buf)
heap_free(args);
return hres;
}
static const IDispatchVtbl BuiltinDispVtbl = {

View File

@ -243,6 +243,11 @@ Call ok(UBound(x) = 2, "UBound(x) = " & UBound(x))
Call ok(getVT(UBound(x, 1)) = "VT_I4", "getVT(UBound(x, 1)) = " & getVT(UBound(x, 1)))
Call ok(UBound(x, 1) = 2, "UBound(x) = " & UBound(x, 1))
x = Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33)
ok x(1) = 2, "x(1) = " & x(1)
ok x(32) = 33, "x(32) = " & x(32)
ok ubound(x) = 32, "ubound(x) = " & ubound(x)
Dim arr2(2, 4)
Call ok(UBound(arr2) = 2, "UBound(x) = " & UBound(x))
Call ok(UBound(arr2, 1) = 2, "UBound(x) = " & UBound(x))