[PATCH 2/2] vbscript: Handle null arguments in DateSerial().

Nikolay Sivov nsivov at codeweavers.com
Thu May 19 02:49:42 CDT 2022


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 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 62b41cea39d..1aaea9de345 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -2092,6 +2092,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 3429a1bbef5..ff1cf8fc5a6 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)
-- 
2.35.1




More information about the wine-devel mailing list