vbscript: Fix handling null argument in CStr.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-08-21 20:22:46 +02:00 committed by Alexandre Julliard
parent c9a606faf6
commit fb5b0c6463
2 changed files with 11 additions and 0 deletions

View File

@ -528,6 +528,9 @@ static HRESULT Global_CStr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
TRACE("%s\n", debugstr_variant(arg)); TRACE("%s\n", debugstr_variant(arg));
if(V_VT(arg) == VT_NULL)
return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
hres = to_string(arg, &str); hres = to_string(arg, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -129,6 +129,14 @@ TestCStr 3, "3"
if isEnglishLang then TestCStr 3.5, "3.5" if isEnglishLang then TestCStr 3.5, "3.5"
if isEnglishLang then TestCStr true, "True" 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(120)) = "VT_BSTR", "getVT(Chr(120)) = " & getVT(Chr(120)))
Call ok(getVT(Chr(255)) = "VT_BSTR", "getVT(Chr(255)) = " & getVT(Chr(255))) Call ok(getVT(Chr(255)) = "VT_BSTR", "getVT(Chr(255)) = " & getVT(Chr(255)))
Call ok(Chr(120) = "x", "Chr(120) = " & Chr(120)) Call ok(Chr(120) = "x", "Chr(120) = " & Chr(120))