Jacek Caban : vbscript: Allow arbitrary number of arguments in builtin functions.
Alexandre Julliard
julliard at winehq.org
Mon Nov 4 16:40:26 CST 2019
Module: wine
Branch: master
Commit: 2dceea6f35ae607c781a6452aa020244ac3a6cc6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2dceea6f35ae607c781a6452aa020244ac3a6cc6
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Nov 4 17:37:57 2019 +0100
vbscript: Allow arbitrary number of arguments in builtin functions.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/vbscript/global.c | 16 +++++++++++++---
dlls/vbscript/tests/api.vbs | 5 +++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 4171df3915..e4ff572412 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -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 = {
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index afa0c2bb1f..d4f3eeaa47 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -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))
More information about the wine-cvs
mailing list