Nikolay Sivov : vbscript: Handle null arguments in DateSerial().

Alexandre Julliard julliard at winehq.org
Thu May 19 16:15:13 CDT 2022


Module: wine
Branch: master
Commit: f6d184fe8833e00484e65e8a30c1a4fa0d7a17bb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f6d184fe8833e00484e65e8a30c1a4fa0d7a17bb

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu May 19 20:17:04 2022 +0300

vbscript: Handle null arguments in DateSerial().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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)




More information about the wine-cvs mailing list