[PATCH v2 0/1] MR10450: vbscript: Return correct error for array dimension mismatch and NULL array access.
Return VBSE_OUT_OF_BOUNDS (error 9, "Subscript out of range") instead of E_FAIL for array dimension mismatch in array_access() and for NULL SAFEARRAY access in variant_call() and do_mcall(), matching native Windows behavior. -- v2: vbscript: Return correct error for array dimension mismatch and NULL array access. https://gitlab.winehq.org/wine/wine/-/merge_requests/10450
From: Francis De Brabandere <francisdb@gmail.com> Return VBSE_OUT_OF_BOUNDS (error 9, "Subscript out of range") instead of E_FAIL for array dimension mismatch in array_access() and for NULL SAFEARRAY access in variant_call() and do_mcall(), matching native Windows behavior. --- dlls/vbscript/interp.c | 34 +++++++++++++++----------------- dlls/vbscript/tests/lang.vbs | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 00ef7d93eb6..17e5bad60c2 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -527,8 +527,8 @@ HRESULT array_access(SAFEARRAY *array, DISPPARAMS *dp, VARIANT **ret) HRESULT hres; if(!array) { - FIXME("NULL array\n"); - return E_FAIL; + WARN("NULL array\n"); + return MAKE_VBSERROR(VBSE_OUT_OF_BOUNDS); } hres = SafeArrayLock(array); @@ -536,9 +536,9 @@ HRESULT array_access(SAFEARRAY *array, DISPPARAMS *dp, VARIANT **ret) return hres; if(array->cDims != argc) { - FIXME("argc %d does not match cDims %d\n", dp->cArgs, array->cDims); + WARN("argc %d does not match cDims %d\n", dp->cArgs, array->cDims); SafeArrayUnlock(array); - return E_FAIL; + return MAKE_VBSERROR(VBSE_OUT_OF_BOUNDS); } indices = malloc(sizeof(*indices) * argc); @@ -583,29 +583,27 @@ static HRESULT variant_call(exec_ctx_t *ctx, VARIANT *v, unsigned arg_cnt, VARIA case VT_DISPATCH: vbstack_to_dp(ctx, arg_cnt, FALSE, &dp); hres = disp_call(ctx->script, V_DISPATCH(v), DISPID_VALUE, &dp, res); - break; + stack_popn(ctx, arg_cnt); + return hres; default: FIXME("unsupported on %s\n", debugstr_variant(v)); return E_NOTIMPL; } - if(array) { - if(!res) { - FIXME("no res\n"); - return E_NOTIMPL; - } - - vbstack_to_dp(ctx, arg_cnt, FALSE, &dp); - hres = array_access(array, &dp, &v); - if(FAILED(hres)) - return hres; + if(!res) { + FIXME("no res\n"); + return E_NOTIMPL; + } + vbstack_to_dp(ctx, arg_cnt, FALSE, &dp); + hres = array_access(array, &dp, &v); + if(SUCCEEDED(hres)) { V_VT(res) = VT_BYREF|VT_VARIANT; V_BYREF(res) = v; } stack_popn(ctx, arg_cnt); - return S_OK; + return hres; } static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res, BSTR identifier, unsigned arg_cnt, BOOL is_call) @@ -894,8 +892,8 @@ static HRESULT assign_ident(exec_ctx_t *ctx, BSTR name, WORD flags, DISPPARAMS * } if(!array) { - FIXME("null array\n"); - return E_FAIL; + WARN("null array\n"); + return MAKE_VBSERROR(VBSE_OUT_OF_BOUNDS); } hres = array_access(array, dp, &v); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index e0feba54b7e..c7d7491d8c5 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1927,6 +1927,44 @@ call TestReDimPreserveByRef(rx) ok ubound(rx) = 7, "ubound(rx) = " & ubound(rx) ok rx(3) = 2, "rx(3) = " & rx(3) +' Array dimension mismatch: should give error 9 (Subscript out of range) +dim dimArr2d(3, 3) +dimArr2d(0, 0) = "hello" +on error resume next + +' 2D array accessed with 1 index +err.clear +y = dimArr2d(0) +ok err.number = 9, "2D array 1 index: err.number = " & err.number + +' 1D array accessed with 2 indices +dim dimArr1d(3) +err.clear +y = dimArr1d(0, 0) +ok err.number = 9, "1D array 2 indices: err.number = " & err.number + +' 2D array accessed with 3 indices +err.clear +y = dimArr2d(0, 0, 0) +ok err.number = 9, "2D array 3 indices: err.number = " & err.number + +' Assign to 2D array with 1 index +err.clear +dimArr2d(0) = "test" +ok err.number = 9, "assign 2D array 1 index: err.number = " & err.number + +' Assign to 1D array with 2 indices +err.clear +dimArr1d(0, 0) = "test" +ok err.number = 9, "assign 1D array 2 indices: err.number = " & err.number + +' Uninitialized dynamic array access +dim dimDynArr() +err.clear +y = dimDynArr(0) +ok err.number = 9, "uninitialized dynamic array access: err.number = " & err.number +on error goto 0 + Class ArrClass Dim classarr(3) Dim classnoarr() -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10450
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10450
@jacek I would like to see the windows tests not fail. Currently all windows runs fail and this is not visible here! Runtime platform arch=amd64 os=windows pid=7860 revision=7178588d version=15.5.1 ERROR: Downloading artifacts from coordinator... error couldn't execute GET against https://gitlab.winehq.org/api/v4/jobs/243440/artifacts?direct_download=true: Get "https://gitlab.winehq.org/api/v4/jobs/243440/artifacts?direct_download=true": dial tcp: lookup gitlab.winehq.org: no such host id=243440 token=glcbt-64 WARNING: Retrying... error=invalid argument -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10450#note_133880
On Thu Mar 26 14:12:48 2026 +0000, Francis De Brabandere wrote:
@jacek I would like to see the windows tests not fail. Currently all windows runs fail and this is not visible here! Runtime platform arch=amd64 os=windows pid=7860 revision=7178588d version=15.5.1 ERROR: Downloading artifacts from coordinator... error couldn't execute GET against https://gitlab.winehq.org/api/v4/jobs/243440/artifacts?direct_download=true: Get "https://gitlab.winehq.org/api/v4/jobs/243440/artifacts?direct_download=true": dial tcp: lookup gitlab.winehq.org: no such host id=243440 token=glcbt-64 WARNING: Retrying... error=invalid argument It seems there is an infrastructure issue with CI, tests pass for me locally on Windows.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10450#note_133884
On Thu Mar 26 14:21:36 2026 +0000, Jacek Caban wrote:
It seems there is an infrastructure issue with CI, tests pass for me locally on Windows. Ok, maybe wait for the newer MR's then as I would really like those to be validated and it's not your job to play CI for me :-)
I test on windows on the vbscript level but only compile wine on linux -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10450#note_133890
participants (3)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb) -
Jacek Caban (@jacek)