From: Francis De Brabandere <francisdb@gmail.com> Native VBScript raises error 458 (VBSE_INVALID_TYPELIB_VARIABLE) when an expression involves a Variant whose type is one of VT_UI2/VT_UI4/ VT_UI8/VT_UINT, on both 32-bit and 64-bit. Add a script-level type gate at the entry of var_cmp so BSTR-vs-{UI2,UI4,UI8,UINT} comparisons match. --- dlls/vbscript/interp.c | 13 +++++++++++++ dlls/vbscript/tests/lang.vbs | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 3cd7921e81a..7ff3baecce8 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -2114,6 +2114,16 @@ static inline BOOL is_numeric_vt(VARTYPE vt) || vt == VT_I1; } +/* Native VBScript rejects these Automation types with error 458 + * (VBSE_INVALID_TYPELIB_VARIABLE) when they appear in script expressions, + * on both 32-bit and 64-bit. VT_I8 is rejected on 32-bit native but + * accepted on 64-bit; not included here so BSTR-vs-I8 falls through to + * the default VarCmp path (BSTR > other), matching 64-bit native. */ +static inline BOOL is_unsupported_script_vt(VARTYPE vt) +{ + return vt == VT_UI2 || vt == VT_UI4 || vt == VT_UI8 || vt == VT_UINT; +} + /* CMP_LEFT_LITERAL / CMP_RIGHT_LITERAL are set by the compiler: each side is * flagged if the source expression at the comparison site is a bare numeric * literal. Native VBScript dispatches BSTR-vs-numeric on this distinction @@ -2127,6 +2137,9 @@ static HRESULT var_cmp(exec_ctx_t *ctx, VARIANT *l, VARIANT *r, unsigned flags) TRACE("%s %s\n", debugstr_variant(l), debugstr_variant(r)); + if(is_unsupported_script_vt(lvt) || is_unsupported_script_vt(rvt)) + return MAKE_VBSERROR(VBSE_INVALID_TYPELIB_VARIABLE); + /* BSTR vs numeric LITERAL: coerce BSTR to a number, parse failure raises * type-mismatch (error 13). */ if((lvt == VT_BSTR && is_numeric_vt(rvt) && r_lit) || diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index b007b3629f6..1477fab16c1 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -260,11 +260,11 @@ Call ok(saved_err = 458, _ "BSTR = testobj.ui8val should err 458, got " & saved_err) Err.Clear : cmp_result = ("5" = testobj.ui2val) : saved_err = Err.number : Err.Clear -Call todo_wine_ok(saved_err = 458, _ +Call ok(saved_err = 458, _ "BSTR = testobj.ui2val should err 458, got " & saved_err) Err.Clear : cmp_result = ("5" = testobj.ui4val) : saved_err = Err.number : Err.Clear -Call todo_wine_ok(saved_err = 458, _ +Call ok(saved_err = 458, _ "BSTR = testobj.ui4val should err 458, got " & saved_err) Err.Clear : cmp_result = ("5" = testobj.uintval) : saved_err = Err.number : Err.Clear -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10775