From f6d184fe8833e00484e65e8a30c1a4fa0d7a17bb Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 19 May 2022 20:17:04 +0300 Subject: [PATCH] vbscript: Handle null arguments in DateSerial(). Signed-off-by: Nikolay Sivov Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/vbscript/global.c | 3 +++ dlls/vbscript/tests/api.vbs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 84d3344918a..5280730f19f 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -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); diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index d27c373a964..0e5b0ee6d37 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -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)