Module: wine Branch: master Commit: fb5b0c64639c056d55e14011a3b4e6f2d83e7cda URL: https://source.winehq.org/git/wine.git/?a=commit;h=fb5b0c64639c056d55e14011a...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Aug 21 20:22:46 2019 +0200
vbscript: Fix handling null argument in CStr.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/vbscript/global.c | 3 +++ dlls/vbscript/tests/api.vbs | 8 ++++++++ 2 files changed, 11 insertions(+)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 17759b8..0797403 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -528,6 +528,9 @@ static HRESULT Global_CStr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
TRACE("%s\n", debugstr_variant(arg));
+ if(V_VT(arg) == VT_NULL) + return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE); + hres = to_string(arg, &str); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index cbffcf4..93cf7f8 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -129,6 +129,14 @@ TestCStr 3, "3" if isEnglishLang then TestCStr 3.5, "3.5" if isEnglishLang then TestCStr true, "True"
+sub testCStrError() + on error resume next + Error.clear() + CStr(null) + call ok(Err.number = 94, "Err.number = " & Err.number) +end sub +call testCStrError() + Call ok(getVT(Chr(120)) = "VT_BSTR", "getVT(Chr(120)) = " & getVT(Chr(120))) Call ok(getVT(Chr(255)) = "VT_BSTR", "getVT(Chr(255)) = " & getVT(Chr(255))) Call ok(Chr(120) = "x", "Chr(120) = " & Chr(120))