vbscript: Handle null arguments in DateSerial().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2022-05-19 20:17:04 +03:00 committed by Alexandre Julliard
parent da966b4d46
commit f6d184fe88
2 changed files with 14 additions and 0 deletions

View File

@ -2095,6 +2095,9 @@ static HRESULT Global_DateSerial(BuiltinDisp *This, VARIANT *args, unsigned args
assert(args_cnt == 3);
if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL || V_VT(args + 2) == VT_NULL)
return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
hres = to_int(args, &year);
if (SUCCEEDED(hres))
hres = to_int(args + 1, &month);

View File

@ -1972,12 +1972,23 @@ end sub
sub testDateSerialError()
on error resume next
dim x
call Err.clear()
call DateSerial(10000, 1, 1)
call ok(Err.number = 5, "Err.number = " & Err.number)
call Err.clear()
call DateSerial(-10000, 1, 1)
call ok(Err.number = 5, "Err.number = " & Err.number)
call Err.clear()
x = DateSerial(null, 1, 1)
call ok(Err.number = 94, "Err.number = " & Err.number)
call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x))
call Err.clear()
call DateSerial(2000, null, 1)
call ok(Err.number = 94, "Err.number = " & Err.number)
call Err.clear()
call DateSerial(2000, 1, null)
call ok(Err.number = 94, "Err.number = " & Err.number)
end sub
call testDateSerial(100, 2, 1, 100, 2, 1)